I have a page that contains two separate queries from two separate databases outputting data in two separate tables.
The first query runs correctly. There is no problem with it.
When the second query is run, I get an error: mysql_num_rows(): supplied argument is not a valid MySQL result resource .
From what I have found, a common cause of this is the failure to connect to the database.
Here is my php code:
$conn = mysql_connect("localhost","username","password") or die ("<br>".mysql_error());
mysql_select_db("database_name") or die(mysql_error());
$results = mysql_query ("SELECT * FROM tbl ORDER BY date DESC");
$totalcount = mysql_num_rows($results);
$lastdate = date("m/d/y");
$dailycount = 0;
echo "Total: <strong>$totalcount</strong><br><br>\n";
I have an insert query running on another page with the exact same credentials as this query and it runs fine - inserting records as it should.
What am I missing here?