Jump to content

[SOLVED] Mysql return issue


frist44

Recommended Posts

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

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);
}

?>

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.