Hi,
I am having problems with a simple count query. I don't code all of the db connection and query code in one script, I separate it out. I've tried to include the code that isn't working here.
I have 30 queries or so that I have absolutely no problems with. If I copy and paste this sql statement into php Admin window and run it.... IT WORKS - It just doesnt't give an accurate count of rows in this table when I use the php mySQL functions.
The query runs - the result set is valid, the 'SELECT COUNT' returns a count of zero. - When I run a SELECT COUNT query in php Admin I get a real number, the actual number of rows, I KNOW there's rows in this ADMIN_SESSION table.
The code is below:
$sql_statement = "SELECT COUNT(*) FROM ADMIN_SESSION";
// SQL Query -
$result=mysql_query($sql_statement, $db_link);
$count_array = mysql_fetch_row($result);
///this is just for testing, I usually return the result set back
echo "The SQL is " . $sql_statement . "
The count inside the db program is: " . $count_array[0] ";
return $result;
-- The result gets passed back to a calling function that executes business logic.
I don't understand when to use mysql_fetch_row() or when to use mysql_fetch_array() or one of the other mysql functions
???????????
I know when I run the SELECT query in phpAdmin I get a true count of the rows (it's not zero), when I use the php mysql functions it runs without an error but doesn't give the correct count:
$sql_statement = "SELECT COUNT(*) FROM ADMIN_SESSION";
$result=mysql_query($sql_statement, $db_link);
$count_array = mysql_fetch_row($result);
that $count_array[0] does not have the count of rows.......
Any Help Is Appreciated!!