Have have similar code to below on multiple pages on my site. This code was referenced from php.net and other site and tutorials as a way of looking through a mysql table. This code has worked then not worked then worked again… with no changing of the code.
The code
[php]
$sql_len1 = mysql_num_rows($result);
for ($i = 0; $i <= $sql_len1; $i++) {
$row = mysql_fetch_array($result);
if (stripslashes($row[‘photo_num’]) > $photo_num) {
$photo_num = stripslashes($row[‘photo_num’]);
}
}
[/php]
The code for $result is as follows:
[php]
$db = mysql_connect(“localhost”, “user”, “pass”);
mysql_select_db(“user_photoalbum”, $db);
$result = mysql_query(“SELECT * from photo”, $db);
[/php]
Now when I run this I will get an error like this
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Can you help for why this works then doesn’t and how to get around that?
Thank you for your help.