search

Home  >  Q&A  >  body text

Please how to solve this: Note: Undefined index: id in D:\phpStudy\WW\Student Management System\edit.php on line 13 Note: Undefined index in D:\phpStudy\WW\Student Management System\edit on line 18 Cannot convert object of class mysqli_result to int in .php

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> ;Student Management System</title>
</head>
<body>
<?php include ('menu.php');
//Link database
header("content-type:text/html;charset=utf8");
$conn=mysqli_connect("localhost","root","root","edu");
mysqli_set_charset($conn, "utf8");
$id=$_GET['id'];
//Execute sql
$sql_select = "select * from stu where id='id'";
$stmt = mysqli_query($conn,$sql_select);
//Judgment
if ($stmt > 0)
{
$stu = mysqli_fetch_assoc($stmt); // Parse data
}else{
die("No such id:{$_GET['id']}");
}
?>
<h3>Modify student information</h3>
<form action="action.php?action=edit" method="post">
<input type="hidden" name="id" value="<?php echo $stu ['id'];?>">
                                                          ="text" name="name" value="<?php echo $stu['name'];?>"></td>
              </tr>
                   ;
                                                                                               ?>"></td>
                                                                            < ;input type="radio" name="sex" value="Male" <?php echo ($stu['sex'] == "Male")? "checked":"";?> >Male
                                                                                                                                                   = "female")? "checked":"";?> >female
           </td>
       </tr>
       <tr>
           <td>班级</td>
           <td><input type="text" name="class" value="<?php echo $stu['class']?>"></td>
       </tr>
       <tr>
           <td a href="index.php">返回</td>
           <td><input type="submit" value="修改"></td>
           <td><input type="reset" value="重置"></td>
       </tr>
   </table>
</form>
</body>
</html>

忆思梦始忆思梦始2645 days ago2036

reply all(6)I'll reply

  • sunten

    sunten2019-02-13 21:25:57

    Encountered the same problem, if the modification is successful, the prompt is:

    Notice: Object of class mysqli_result could not be converted to int in E:\phpStudy\WWW\stu\edit.php on line 19

    reply
    0
  • phpcn_u37517

    phpcn_u375172017-11-23 12:23:46

    You use post to send the value and use get to receive it. I guess it’s hard to receive it.

    reply
    0
  • 忆思梦始

    Ok, I understand

    忆思梦始 · 2017-11-23 12:26:16
  • phpcn_u37517

    phpcn_u375172017-11-22 17:57:52

    There is something wrong with the link database

    reply
    0
  • 忆思梦始

    The database is ok, mainly because the id that you click to modify is not obtained<Add ..php?id=$id{$row['id']}> where you click to modify.

    忆思梦始 · 2017-11-23 12:21:45
  • Cancelreply