我正在成功地从数据库表中选择数据,当我试图在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()
没有获取数据呢?
答案 0 :(得分:3)
在$ chkname中更改为email = $name
(删除点)或email = '$name'
你正在使用mysql,而是使用mysqli或pdo sql