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 :(

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.