Hey all,
Im trying to learn mysql+php lately, and I think I have most of it configed right but it gives this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /path/to/www/index.php on line 89
But when I test the command using this, it goes to the <=0 and says no entries found, but still displays the error.
@ $db = mysql_connect("host","user","pass");
if(!$db) { echo "Error: Could not connect"; }
mysql_select_db("DBname", $db) or die("Failed to select db" .mysql_error());
// I have the above in a separate file, including it with php.
$query = "select * from DBname";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
if ($num_results <= 0) {
echo "<td colspan=6>No database entries found</td>";
} else {
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<td>" .stripslashes($row['val1']). "</td>";
echo "<td>" .stripslashes($row['val2']). "</td>";
echo "<td>" .stripslashes($row['val3']). "</td>";
echo "<td>" .stripslashes($row['val4']). "</td>";
echo "<td>" .stripslashes($row['val5']). "</td>";
echo "<td>" .stripslashes($row['val6']). "</td>";
}