得到通知未定义索引
getting notice undefined index
我已阅读以下内容 PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" 但是我还没有弄清楚我的问题所在。
我得到下面的 notice:undefined 索引,据我所知我已经定义了 infoID:
Notice: Undefined index: infoID in
C:\xampp\htdocs\WebDevelopment\Bathrooms\functions.php on line 193
function info_byidx($sql) {
include 'connect.php';
$id = $_GET['infoID'];
$select = $conn->prepare($sql);
$select->bind_param('s', $id);
$select->execute();
$select->store_result();
if ($select->num_rows > 0) {
$meta = $select->result_metadata();
while ($field = $meta->fetch_field()) {
$params[] = &$row[$field->name];
}
call_user_func_array(array($select, 'bind_result'), $params);
while ($select->fetch()) {
if ($row['title'] == "NULL") {
echo "<h3>".$row['subtitle']."</h3>\n<p>".$row['content']."</p>\n";
}
else if ($row['subtitle'] == "NULL") {
echo "<h2>".$row['title']."</h2>\n<p>".$row['content']."</p>\n";
}
else {
echo "<h2>".$row['title']."</h2>\n<h3>".$row['subtitle']."</h3>\n<p>".$row['content']."</p>\n";
}
}
$select->close();
}
}
infoID 通过以下方式定义:
http://localhost:1234/WebDevelopment/Bathrooms/info.php?pageID=2?infoID=x
-- where is the value of generalID
http://localhost:1234/WebDevelopment/Bathrooms/info.php?pageID=2?infoID=x
修正为
http://localhost:1234/WebDevelopment/Bathrooms/info.php?pageID=2&infoID=x
就一个?首先,然后使用 & 分隔下一个 key=values.
我已阅读以下内容 PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" 但是我还没有弄清楚我的问题所在。
我得到下面的 notice:undefined 索引,据我所知我已经定义了 infoID:
Notice: Undefined index: infoID in C:\xampp\htdocs\WebDevelopment\Bathrooms\functions.php on line 193
function info_byidx($sql) {
include 'connect.php';
$id = $_GET['infoID'];
$select = $conn->prepare($sql);
$select->bind_param('s', $id);
$select->execute();
$select->store_result();
if ($select->num_rows > 0) {
$meta = $select->result_metadata();
while ($field = $meta->fetch_field()) {
$params[] = &$row[$field->name];
}
call_user_func_array(array($select, 'bind_result'), $params);
while ($select->fetch()) {
if ($row['title'] == "NULL") {
echo "<h3>".$row['subtitle']."</h3>\n<p>".$row['content']."</p>\n";
}
else if ($row['subtitle'] == "NULL") {
echo "<h2>".$row['title']."</h2>\n<p>".$row['content']."</p>\n";
}
else {
echo "<h2>".$row['title']."</h2>\n<h3>".$row['subtitle']."</h3>\n<p>".$row['content']."</p>\n";
}
}
$select->close();
}
}
infoID 通过以下方式定义:
http://localhost:1234/WebDevelopment/Bathrooms/info.php?pageID=2?infoID=x
-- where is the value of generalID
http://localhost:1234/WebDevelopment/Bathrooms/info.php?pageID=2?infoID=x
修正为
http://localhost:1234/WebDevelopment/Bathrooms/info.php?pageID=2&infoID=x
就一个?首先,然后使用 & 分隔下一个 key=values.