1

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

代码部分是:

<?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 个字段,但为什么会显示,我无法在表单字段中看到数据以进行编辑。请帮助我解决这个问题。

4

3 回答 3

0

检查以确保 $_REQUEST 保存了变量。

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

于 2012-04-12T21:15:29.507 回答
0

显然${$field}评估为"0"并且$query["0"]未定义。

于 2012-04-12T21:24:47.123 回答
0

你可以使用这个快速修复isset

if(isset($GLOBALS[${$field}]))
{
    ${$field} = $query [$field];
}
于 2012-04-12T21:28:10.073 回答