Page 1 of 1

PHP Query for WHERE MySQL Statement not working

Posted: Sun Sep 10, 2006 5:58 am
by richo
Hi, i'm working on a slideshow,

I'm using a query string that should dictate which image etc is displayed.

I'm using this query in a WHERE statement, comparing it to the primary key of the row to select the relevant information.

BUT, the only thing it brings back is:

Resource id #5

My code is below:

Code: Select all

if (!empty($_REQUEST)) {
	$slide = $_REQUEST["slide"];
}
else {
	$slide = 1;
}

$img = mysql_query("SELECT img FROM slides WHERE pkey = '$_REQUEST[slide]'");
further down:

Code: Select all

<?php echo "<img src=\"" . $img . "\" />"; ?>
I'm totally stuck, please help!?

Problem Solved

Posted: Sun Sep 10, 2006 6:04 am
by richo
I had not worked it properly.

See new code below:

Code: Select all

$result2 = mysql_query("SELECT img FROM slides WHERE pkey = '$_REQUEST[slide]'");
$img = mysql_fetch_array($result2);

Code: Select all

<?php echo "<img src=\"" . $img["img"] . "\" />"; ?>