gpt4 book ai didi

php - 如何修复我的程序?

转载 作者:行者123 更新时间:2023-12-04 04:32:28 25 4
gpt4 key购买 nike

我的代码有什么问题,我该如何解决我的问题?

<?php
require_once('db.php');
$q="SELECT * FROM student WHERE Id=1";
$rs=mysql_query($q);
$count=mysql_num_rows($rs);
echo $count;
if($count!=0){
while($result=mysql_fetch_array($count)){
echo $result['Id']."<br/>";
echo $result['Name']."<br/>";
echo $result['Dept']."<br/>";
echo $result['Email']."<br/>";
echo $result['Gender']."<br/>";
echo $result['Cgpa']."<br/>";
echo $result['Password']."<br/>";
}
}
else
{
die("There is a error in database parsing");
}
?>

错误信息:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\FinalProject\admin\login_admin.php on line 58

数据库解析出错

最佳答案

  • 停止使用 mysql_*功能,它们已被弃用,并将在 future 的某个时候完全删除。
  • 你应该做 $result = mysql_fetch_array($result) ,不是 $count .
  • 关于php - 如何修复我的程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20357774/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com