PHP Query for WHERE MySQL Statement not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
richo
Forum Commoner
Posts: 58
Joined: Sun Aug 06, 2006 11:56 am

PHP Query for WHERE MySQL Statement not working

Post 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!?
richo
Forum Commoner
Posts: 58
Joined: Sun Aug 06, 2006 11:56 am

Problem Solved

Post 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"] . "\" />"; ?>
Post Reply