gpt4 book ai didi

php - mysql_num_rows 返回零

转载 作者:行者123 更新时间:2023-11-29 12:29:48 26 4
gpt4 key购买 nike

<?php 
session_start();
$con=mysql_connect("localhost","root","samy");
mysql_select_db("project");
if($con)
{
echo "Connected Successfully ";
}
else
{
echo "Error" . $sql . "<br>" . mysql_connect_error();
}
$name=$_SESSION['name'];
echo $name;
$sql1 = mysql_query("select cust_id from registered_user where name ='.$name.' ");
$r = mysql_num_rows($sql1);
echo $r;
$row1 = mysql_fetch_array($sql1);
$cid = $row1['cust_id'];
echo $cid;
?>

由于 num_rows 返回零,因此 $cid 也不会打印。不知道错误是什么;

最佳答案

您应该删除点(.)

$sql1 = mysql_query("select cust_id from registered_user where name ='$name'");
^ ^

还建议添加这样的错误报告

$sql1 = mysql_query("select cust_id from registered_user where name ='$name'") 
or die(mysql_error());

关于php - mysql_num_rows 返回零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27732220/

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