my version of php is 4.4.5 and mysql is 5.0.33
I have phpmyadmin installed and ran this query from within phpmyadmin:
SELECT COUNT ( * ) AS Rows FROM copper_pictures LEFT JOIN copper_comments ON copper_pictures.pid = copper_comments.pid WHERE owner_id = 2 AND author_id != 2
basically it is a way of getting the number of comments that others have left on your images , not including you own comments (in coppermine photo gallery).
Well it runs fine and returns the number 23, which I checked and is acurate.
But for some reason it is not parsing when put through php.
here is my php code:
//number of comments left by others on your images
$num_comments_left = "SELECT COUNT ( * ) AS `Rows` FROM `copper_pictures` LEFT JOIN `copper_comments` ON `copper_pictures`.pid = `copper_comments`.pid WHERE `owner_id` = 2 AND `author_id` != 2";
$result = mysql_query($num_comments_left);
$bow = mysql_fetch_assoc($result);
echo "Comments left by others on your images: ".$bow['Rows'];
And this is the lovely error message I am getting:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\index.php on line 11
any ideas why this works fine in phpmyadmin but breaks in php...other queries with similar syntax work fine
...e.g. this works works without any problems:
//Images uploaded
$num_uploads = "SELECT COUNT( * ) AS `Rows` FROM `copper_pictures` WHERE `owner_id` = $user_id";
$result = mysql_query($num_uploads);
$bow = mysql_fetch_assoc($result);
echo "Images uploaded: ".$bow['Rows'];