php - 为什么这个通知(12次): Uninitialized string offset: 0 in app_vsf. php on line 90

标签 php mysql

请帮助我解决标题中指定的问题。

代码部分是:

<?php
// framework related things in this file.

// vsf = Very Simple Framework

$vsf = new stdClass;

// default app_layout file
$vsf->app_layout = 'app_layout.php';

// define the 'index' file, where we should link back to.
// Need to include the path, otherwise S.E. friendly URLS get messed up.
$vsf->self = '/mapcal/index.php';

// to support search engine friendly URLS, grab data from PATH_INFO
if (isset($_SERVER["PATH_INFO"]) ) {
$tmp_array = explode("/",$_SERVER["PATH_INFO"]);

for ($index = 0; $index < count($tmp_array); $index++) {
// only want the odd elements, they are the parameters.  The even ones are the values
if ( $index % 2 == 0 ) { continue; }
$_REQUEST[$tmp_array[$index]] = $tmp_array[$index+1];
}
}

// these functions are for form error handling
$errorfields = array();

$errormsgs = array();

$errorwasthrown = FALSE;

function adderrmsg($field = '', $msg = '') {
global $errorfields;
global $errormsgs;
global $errorwasthrown;

if ($field) {
$errorfields[] = $field;
}
if ($msg) {
$errormsgs[] = $msg;
}
$errorwasthrown = TRUE;
}

function displayformerrors($errhdr = 'The following errors occured:') {
global $errorfields;
global $errormsgs;

if ( empty($errorfields) and empty($errormsgs) ) {return;}

if (! empty($errormsgs) ) {
print "<p style='color: red;'>$errhdr<br>\n";

foreach ($errormsgs as $msg) {
  print "&#8226; $msg<br>\n";
  }
print "</p>\n\n";
}
}

function displayformlabel ($field = '', $label = '') {
global $errorfields;
if ( in_array($field,$errorfields) ) {
print "<span style='color: red;'>$label</span>";
}
else {
print $label;
}
}

function reuseform($formaction = 'new',$field_list = '',$query = '') {
if ($formaction == "new") {
foreach (split(",",$field_list) as $field) {
  global ${$field};
  ${$field} = '';
  }
}
elseif ($formaction == 'form') {
foreach (split(",",$field_list) as $field) {
  global ${$field};
  ${$field} = $_REQUEST[$field];
  }
}

elseif ($formaction == 'query') {
foreach (split(",",$field_list) as $field) {
  global ${$field};
  ${$field} = $query[$field];
  }
}

}  // close function reuseform

?>

第 90 行是:${$field} = $query[$field];

通知显示了 12 次,因为表单中有 12 个字段,但为什么会显示,我无法在表单字段中看到用于编辑目的的数据。 请帮我解决这个问题。

最佳答案

检查以确保 $_REQUEST 持有变量。

此外,reuseform 似乎默认将 $query 设置为 '' 而不是 Array() ... $query 是否设置正确?这个错误说明不是。

关于php - 为什么这个通知(12次): Uninitialized string offset: 0 in app_vsf. php on line 90,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10131930/

相关文章:

php - PDO 对象未正确构造

php - MySQL 加入案例语句

php - 子页面内容

java - 如何根据外键从引用表中获取值?

mysql - SQL 连接 - 为什么这个简单的连接有效,尽管语法毫无意义?

mysql - 哪种方法更好地显示数据库中的大量结果?

php - 多文件上传不保存

php - 计算来自不同列的记录 (MySQL/php)

php - 在 Slack 消息中发送超链接以调用 api

mysql - 简单的sql查询,包含3张表