Jump to content

mysql_num_rows(): supplied argument is not a valid MySQL result resource


mattichu

Recommended Posts

I get the following error:

 

 

with the following code:

 


$username="****";
$password="****";
$database="checkmyw_database";
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query3="SELECT * FROM hours WHERE (out1<>'0' AND in1=='0' OR out2<>'0' AND in2=='0')  && (date==$date)";
$result3=mysql_query($query3);
$num3=mysql_numrows($result3);
mysql_close();

if($num3==0){
$clockedout="true";}

echo $clockedout;

 

Any ideas why :(

Link to comment
Share on other sites

 

Any ideas why

 

yes...

 

http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html

 

other suggestions:

- is always a good idea to echo your raw sql (echo $query3) to debug your code.

- don't use the error suppressor character (@) that only hide possible errors... don't hide them.. control them.

- try to be consistent in the usage of Logical Operators (use AND, OR .. or && and ||) mixing them doesn't look good; even when is not a mistake per se, just a matter of coding habits.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.