|
Posted by Jerry Stuckle on 04/28/06 18:49
ste wrote:
> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
> news:G5udneifg5pfZ8zZnZ2dnUVZ_tGdnZ2d@comcast.com...
> <snip>
>
>>You're close. mysql_query() returns a result object; you need to retrieve
>>the actual data (into $row in your example).
>>
>>After the mysql_query() add the following:
>>
>> $row = mysql_fetch_array($result);
>>
>>
>>--
>>==================
>>Remove the "x" from my email address
>>Jerry Stuckle
>>JDS Computer Training Corp.
>>jstucklex@attglobal.net
>>==================
>
>
> Hi Jerry,
>
> Thanks for getting back to me - I'm close? I'm astonished as I thought I
> would be way out!
>
> I *think* I've put your line of code in the right place, but this still
> doesn't work I'm afraid. When the page opens, there's no image - if I look
> at the HTML, it is basically returning <img src=""> instead of <img
> src="images/image1/jpg">. Perhaps the query is right but my code to insert
> the field name (which contains the image URL, it's called 'imagelocation')
> isn't?
>
> Here's the code again with the extra line - did I put it in the right place?
>
> <?php
> include("my_db_login.inc");
>
> $connection = mysql_connect($host,$user,$password) or die ("couldn't connect
> to server");
> $db = mysql_select_db($database,$connection) or die ("Couldn't select
> database");
>
> $query = "SELECT * FROM my_database WHERE imageid =
> \"{$_POST['imageid']}\"";
> $result = mysql_query($query) or die ("Couldn't execute query.");
> $row = mysql_fetch_array($result);
>
> echo "<img src=\"{$row['imagelocation']}\" width=\"500\" border=\"0\" />";
> ?>
>
> Thanks,
>
> Ste
>
>
Ste,
I have no idea if it is 'imagelocation' or not. It's the name of the MySQL
column containing the information you want.
What happens if you do:
echo "<pre>\n";
print_r($row);
echo "</pre>\n";
This will give you the contents (including keys) of $row.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|