我编写了以下查询
SELECT COUNT(userID) From statistics WHERE userID = ""此查询显示对网站的未授权访问次数。
当我使用双引号时,这个查询可以在phpmyadmin中运行,但是当我使用单引号时,它就不能工作了,如下所示,它只给出了表中存储的记录数
$queryB = "SELECT COUNT(userID) From statistics WHERE userID = ''";
$resultB =mysql_query($queryA, $con) or die(mysql_error());
$authB = mysql_result($resultB, "COUNT(userID)");
echo "the number of authenticated visits were $authB<br />\n";我不知道为什么它坏了,有什么想法吗?
发布于 2012-04-11 22:03:19
不确定它是否会work...its,首先想到的是:当你使用转义双引号的时候呢?
$queryB = "SELECT COUNT( userID ) From statistics WHERE userID=\“\”
发布于 2012-04-11 22:01:29
您将查询存储在$queryB中,但使用了$queryA
发布于 2012-04-11 22:01:58
试试这个:
$queryB = "SELECT COUNT(userID) AS total From statistics WHERE userID = ''";
$resultB =mysql_query($queryB, $con) or die(mysql_error());
$authB = mysql_fetch_assoc($resultB);
echo "the number of authenticated visits were ".$authB['total']."<br />\n";https://stackoverflow.com/questions/10107380
复制相似问题