mattichu Posted March 7, 2012 Share Posted March 7, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/258477-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource/ Share on other sites More sharing options...
batwimp Posted March 7, 2012 Share Posted March 7, 2012 You have mysql_numrows instead of mysql_num_rows. Quote Link to comment https://forums.phpfreaks.com/topic/258477-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1324918 Share on other sites More sharing options...
xyph Posted March 7, 2012 Share Posted March 7, 2012 You're getting a query error. Quote Link to comment https://forums.phpfreaks.com/topic/258477-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1324919 Share on other sites More sharing options...
AyKay47 Posted March 7, 2012 Share Posted March 7, 2012 you are using the php operators in your sql statement. $query3="SELECT * FROM hours WHERE (out1 <> '0' AND in1 = '0') OR (out2 <> '0' AND in2 = '0') AND `date` = $date"; Quote Link to comment https://forums.phpfreaks.com/topic/258477-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1324924 Share on other sites More sharing options...
mikosiko Posted March 7, 2012 Share Posted March 7, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/258477-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1324928 Share on other sites More sharing options...
mattichu Posted March 7, 2012 Author Share Posted March 7, 2012 ledge! cheers addict! x Quote Link to comment https://forums.phpfreaks.com/topic/258477-mysql_num_rows-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1324929 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.