MySQL查询不返回行,phpMyAdmin在同一查询中返回1行,没有错误


MySQL Query returns no rows and no errors where phpMyAdmin returns 1 row in the same query

我完全不知道这里发生了什么。

下面是我的代码:

    $sid = "123";
    $sid_query_conf = mysql_query("SELECT email FROM users WHERE sid='$sid'");
if(!$sid_query_conf)
    die(mysql_error());
$result = mysql_fetch_assoc($sid_query_conf);
if(mysql_num_rows($result) == 0)
    die("Error processing your details");

它一直返回"错误处理您的详细信息"在哪里是phpMyAdmin我得到我正在寻找的结果。在此之前甚至有一个查询,所以我知道连接在这方面是有效的。

我甚至试图从表中选择一切,它仍然没有返回行。Mysql_fetch_result也没有执行任何操作。

我真的需要一些帮助,知道是什么使它不像这样工作。

我认为mysql_num_rows($result)应该是mysql_num_rows($sid_query_conf)

你也不应该再使用mysql_*函数了,因为它们已经被弃用了,用PDO或mysqli代替。

http://php.net/manual/en/function.mysql-num-rows.php