我得到一个未定义的索引:对于每个超过一千的 ID。我已尽一切努力使错误消失,并希望有人能够提供帮助。请提前致谢。
$bamid 是从页面调用的,它可以工作。错误来自这个语句“$selected[$id]”,如果删除它就没有错误。添加双引号或单引号不起作用。
<?
$sql="SELECT * users ORDER BY name ASC";
$result=mysql_query($sql);
$options = "";
while ($row=mysql_fetch_array($result))
{
$id = $row['id'];
$name = $row['name'];
$selected = array($bamid => "selected");
$options.="<option value = \"$id\" $selected[$id]>".$name.'</option>';
}
?>
<select name = "bamid">
<option>-------</option>
<? echo $options?>
</SELECT>
错误日志的示例输出:
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 572 in xxxxxxxxxxxxxxx on line 173
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 833 in xxxxxxxxxxxxxxx on line 173
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 698 in xxxxxxxxxxxxxxx on line 173
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 666 in xxxxxxxxxxxxxxx on line 173
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 546 in xxxxxxxxxxxxxxx on line 173
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 688 in xxxxxxxxxxxxxxx on line 173
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 834 in xxxxxxxxxxxxxxx on line 173
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 312 in xxxxxxxxxxxxxxx on line 173
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 650 in xxxxxxxxxxxxxxx on line 173
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 1109 in xxxxxxxxxxxxxxx on line 173
[Sun Jun 30 01:46:55 2013] [warn] [client xx.xx.xx.xx] mod_fcgid: stderr: PHP Notice: Undefined index: 430 in xxxxxxxxxxxxxxx on line 173