I have a query that is: SELECT COUNT(*) FROM p2 WHERE `time` BETWEEN DATE_SUB(NOW(),INTERVAL 10 MINUTE) AND NOW(); and I am trying to display it in a table, I have copied the code form another php page that I know works, but this query refuses to work.
I have:
Code: Select all
$db = "localhost:3306";
$u = "xx";
$p = "xx";
$dbs = "test";
$posCountQuery = "SELECT COUNT(*) FROM p2 WHERE `time` BETWEEN DATE_SUB(NOW(),INTERVAL 10 MINUTE) AND NOW()";
echo "<table><tr>";
$con = mysql_connect($db,$u,$p);
mysql_select_db($dbs, $con);
$result = mysql_query($posCountQuery, $con);
while ($row = mysql_fetch_assoc($result))
{
foreach ($result as $attribute)
print "<td>$attribute</td>";
}
echo "</tr></table>";
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\local\test2.php on line 10.
I am obviously missing something, but can't for the life of me see what it is?