注意:第33行c:\program files(x86)\easyphp1-8\www\new folder\edit.php中的未定义索引:id

注意:第33行c:\program files(x86)\easyphp1-8\www\new folder\edit.php中的未定义索引:id,php,Php,这是我的密码。。我不知道是什么问题。。单击“提交”按钮后..出现错误。。困了一整天 <? if (isset($_GET['do']) && $_GET['do'] == 'update') { $id=$_POST["id"]; $name=$_POST["name"]; $address=$_POST["address"]; $contact=$_POST["contact"]; $item=$_POST["item"]; $query="update itemord

这是我的密码。。我不知道是什么问题。。单击“提交”按钮后..出现错误。。困了一整天

<?

if (isset($_GET['do']) && $_GET['do'] == 'update')
{
$id=$_POST["id"];
$name=$_POST["name"];
$address=$_POST["address"];
$contact=$_POST["contact"];
$item=$_POST["item"];
$query="update itemorder set name='$name',address='$address',contact='$contact',item='$item' where id=$id";
mysql_query($query);

    echo "<center>Successfully Updated in DATABASE</center>";
    include("search.php");

}
?>
<center>
  <h1><u>Student Database</u></h1>
</center>
<?
$id=$_GET["id"]; //the problem here, line 33
$query="select * from itemorder where id='$id'";
$result=mysql_query($query);
         while ($row = mysql_fetch_array($result)) {

?>

检查您是否使用
$\u POST
$\u GET
,请使用GET或POST,但不能同时使用两者,您的
id
未设置,您的URL没有
?id=25
,请使用
isset(isset($\u GET[“id”])
以避免此错误

或者您可以简单地使用
$\u REQUEST['id']
来获取id数据

<?
if(isset($_GET["id"])){    
$id=$_GET["id"]; //the problem here, line 33    
$query="select * from itemorder where id='$id'";
$result=mysql_query($query);
 while ($row = mysql_fetch_array($result)) {
         // fetch records
}else{
echo  "no records found with the id $id";
}
?>
你错过了一个大括号

while ($row = mysql_fetch_array($result)) {
} //<--- here
?>
while($row=mysql\u fetch\u array($result)){
} //
使用


如果未设置,则必须定义默认值。或者您可以在if条件中定义select查询。

我已经使用了$\u REQUEST['id'],但错误在下一行再次出现。.第34行URL是否有
?id=12
作为扩展名?很抱歉,我是php新手。。那么,如何将?id=12作为扩展名?如何将其放置?像这样的?听着,我改变了答案。做类似的事情嗨,先生,我也使用你的解决方案,但是错误再次出现。。在这一行$query=“select*from itemorder,其中id=”$id';我试试这个,怎么样,先生?如果您的
$id
设置与否,但查询总是执行,因此它总是会给您错误。为此,请尝试
是,这就是我想告诉您的。由于未设置
$id
,因此不会执行任何查询,也不会出现错误。
<?
if(isset($_GET["id"])){    
$id=$_GET["id"]; //the problem here, line 33    
$query="select * from itemorder where id='$id'";
$result=mysql_query($query);
 while ($row = mysql_fetch_array($result)) {
         // fetch records
}else{
echo  "no records found with the id $id";
}
?>
while ($row = mysql_fetch_array($result)) {
} //<--- here
?>
   if(isset($_GET["id"]))
   {
       $id=$_GET["id"];
   }
   else
   { 
       $id=0;
   }