gpt4 book ai didi

php - 为什么 mysql_fetch_array() 存储空结果?

转载 作者:太空宇宙 更新时间:2023-11-03 12:02:51 24 4
gpt4 key购买 nike

我成功地从数据库表中选择了数据,每当我尝试借助 mysql_fetch_array() 将该数据提取到数组中时,它不会将任何内容存储到数组中。

@session.start();
$name=$_SESSION['umailid'];
$chkname1 = "select * from ".USREG." where email='.$name.'";

echo $chkname1;
// it is printing like this:
// " select * from users_temp where email='.subbu66g@gmail.com.' "
// which means query was successful, above email is there in database table

$res1 = mysql_query($chkname1, $con) or die(mysql_error());

$chkresult1 = mysql_fetch_array($res1);
echo $chresult1['name']; //its not printing anything
if ($chkresult1) //it is storing null and entering into else block
{
echo "query successful";
}
else {
echo "query was not successful";
}

结果是“查询不成功”。我认为我的选择查询一切正常。那为什么这个 mysql_fetch_array() 没有获取数据呢?

最佳答案

在 $chkname 中更改为 email = $name(删除点)或 email = '$name'

而你正在使用 mysql,而是使用 mysqli 或 pdo sql

关于php - 为什么 mysql_fetch_array() 存储空结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28221666/

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