I am trying to query a database for the picture id number of the latest entry to my photo album so that I can then echo it to show how many pictures have been submitted.
Currently I have the following script:
<?php
include("/home/www/teenonyM/scripts/database_functions.php");
# Function from the file above.
OpenConnection();
# Assign query to a value that can be passed to the custom error handler.
$query = "SELECT `pic_id` FROM `phpbb_album` WHERE 1 ORDER BY `pic_id` DESC LIMIT 0 , 1 ";
@mysql_query($query, $connection)
or ThrowError("error with query: " . mysql_error() . "\n\nQuery: " . $query);
?>
Which as I expected returns a blank page.
Q1) Is this code correct so far and from this can I use the mysql_fetch_array to set the value of variable to the pic_id value?
After reading the FAQ I tried chaning the above code to:
<?php
include("/home/www/teenonyM/scripts/database_functions.php");
# Function from the file above.
OpenConnection();
# Assign query to a value that can be passed to the custom error handler.
$query = "SELECT `pic_id` FROM `phpbb_album` WHERE 1 ORDER BY `pic_id` DESC LIMIT 0 , 1 ";
@mysql_query($query, $connection)
or ThrowError("error with query: " . mysql_error() . "\n\nQuery: " . $query);
$pics = mysql_fetch_array($query['pic_id']);
echo "$pics";
?>
However I receive the error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/teenonyM/scripts/test.php on line 13
Q2 What does the error message mean and what do I need to change to the code?