1

$rs = mysql_query("SELECT user, userid FROM House WHERE userid='$userid'");

This return Resource id #37 The table House is empty, shouldn't it return FALSE? According to the manual http://php.net/manual/en/function.mysql-query.php

I have always gotten FALSE on error, but not this time. Can someone explain, thanks!

2 Answers 2

8

If there is nothing wrong with your query, then mysql_query() will not return false. An empty result set is not an error.

Calling any of the fetch functions against that result will return false. mysql_num_rows() will return 0.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I did not know that. It's kinda weird that I have coded like this for so long without having problems.
4

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or false on error.

For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc it returns trueon success or false on error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.