Primary key field wont retrieve
Posted: Sun Mar 22, 2009 12:09 am
Hi, I'm trying to retrieve the information from my table but it returns a blank page.
image_id is the primary key in the table and is set to auto increment, is this why i cant retrieve the info? Ive retrieved info from other fields with no problems.
Thanks in advance.
image_id is the primary key in the table and is set to auto increment, is this why i cant retrieve the info? Ive retrieved info from other fields with no problems.
Code: Select all
<?PHP
if (!file_exists("../dbconnect.php"))
{
die("Database settings not found, administrator intervention required.") ;
}
else
{
require("../dbconnect.php") ; //Must connect to the database.
}
//$userrate = $_GET['rating'] ;
$currentimage = 5 ;//$_SESSION['currentimage'] ;
$query = "SELECT image_id FROM image_bank WHERE image_id = '$currentimage'" ;
$result = mysql_query($query) ;
$nrows = mysql_fetch_row($result) ;
while($row = mysql_fetch_array($result))
{
$currentrating = $row['rating'] ;
$numratings = $row['numratings'] ;
echo "is $currentrating $numratings" ;
}
?>