frist44 Posted March 5, 2009 Share Posted March 5, 2009 I know this is probably rediculous. I've been working with a database all day for some pages and it's been fine. I'm now trying to write some command line scripts to report via email and every mysql_num_rows is returning "1"? mysql_connect($host,$user,$password) or die("Unable to connect to database server"); @mysql_select_db($database) or die("Unable to select database"); $query3="SELECT COUNT(*) FROM $table"; $result=mysql_query($query3); echo mysql_num_rows($result); mysql_close(); Link to comment https://forums.phpfreaks.com/topic/148141-solved-mysql-return-issue/ Share on other sites More sharing options...
revraz Posted March 5, 2009 Share Posted March 5, 2009 Because you are only grabbing a COUNT and not actually grabbing any rows. Link to comment https://forums.phpfreaks.com/topic/148141-solved-mysql-return-issue/#findComment-777623 Share on other sites More sharing options...
trq Posted March 5, 2009 Share Posted March 5, 2009 Because a 'SELECT COUNT() query only returns one row. You likely want somthing like.... mysql_connect($host,$user,$password) or die("Unable to connect to database server"); @mysql_select_db($database) or die("Unable to select database"); $query3 = "SELECT COUNT(*) FROM $table"; if ($result=mysql_query($query3)) { echo mysql_result($result,0); } ?> Link to comment https://forums.phpfreaks.com/topic/148141-solved-mysql-return-issue/#findComment-777626 Share on other sites More sharing options...
frist44 Posted March 5, 2009 Author Share Posted March 5, 2009 very true. It's been a long day... Thanks! Link to comment https://forums.phpfreaks.com/topic/148141-solved-mysql-return-issue/#findComment-777637 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.