I know there are mysql results but nevery any in php
I have a query that never returns any results or errors. When I run the sql directly through phpmyadmin the results come back fine.
just trying to dump row right now to see whats coming back
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$sql = "SELECT ProductID,Name FROM products WHERE ProductID > 5 ORDER BY ProductID DESC";
$query = mysql_query($sql);
while ($row = mysql_fetch_object($query)){
var_dump($row);
}
?>never returns a single value. If I place a little text output around the vardump still comes out with nothing.

Replies
remember to select db
Did you remember to select the database?
mysql_select_db($database_name, $link);Also one way to help debug query errors is to place this after any mysql query
echo mysql_error($link);Often if queries fail because of some sort of mysql error your php will just go on fine.
Make sure you remove the error reporting before going live as it often contains information you do not want printed to random visitors.
Post new comment