Why does mysql_query() return TRUE with a SELECT statement?

后端 未结 7 1777
日久生厌
日久生厌 2020-12-20 15:24

According to the manual of mysql_query() and to everything I know about this function that I used so many times, it can either return a resource or FALSE if the

相关标签:
7条回答
  • 2020-12-20 16:06

    When you say it "returns TRUE," how are you testing that? You're not by any chance doing something like this, are you?

    $result = mysql_query($sql);
    if ($result == TRUE) { /* stuff */ }
    

    If so, keep in mind that all non-zero, non-blank, non-null value that is returned will evaluate to TRUE. You can verify this by using the more stringent:

    if ($result === TRUE) { /* stuff */ }
    

    That evaluates not just equivalence, but type as well. Are you doing something like a var_export($result); to check the data type and verify that you're actually getting back the boolean value of TRUE?

    0 讨论(0)
提交回复
热议问题