hvle Posted April 28, 2006 Share Posted April 28, 2006 mysql_num_rows() has strangely failed in Window platform.well, I have this codeLine 1: $sql = "select ......";Line 2: $rs = mysql_query($sql);Line 3: $rowcount = mysql_num_rows($rs);Line 4: somecode herevery basic and it works fine in Linux system my host serverhowever, in my local system (Windows) it failed every time $rs is empty.What happened is if $rs returned a non-empty set, $rowcount will contain number of rows in that $rs and proceed to Line 4.When a select statement that returned an empty set, the script just halt (simply stop and exit) right at Line 3;I have read the PHP documentation on mysql_num_rows() and it does not state any platform incompatiblity regarding this function. I hope somebody with more experiences would explain why it behaved this way.Thanks a million. Quote Link to comment Share on other sites More sharing options...
predator12341 Posted April 28, 2006 Share Posted April 28, 2006 hi can we look at the sql statement you are using please Quote Link to comment Share on other sites More sharing options...
koencalliauw Posted April 28, 2006 Share Posted April 28, 2006 You probably should do something to check if the result set for your query is correct (if there is no sql-error, that is):[code]$sql="select * from employees";$res=@mysql_query($sql);if($res!=FALSE){ echo mysql_num_rows($res);}else{ echo "There was an error in your SQL query: " . mysql_error() . "\n<br />The given SQL query was: " . $sql;}[/code] Quote Link to comment Share on other sites More sharing options...
hvle Posted April 28, 2006 Author Share Posted April 28, 2006 Thanks for all replies, After a lot of testing, i found the error on another module. The problem is not mysql_num_rows Quote Link to comment 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.