Re: Problems Creating the Code to Open Images Within a Template PHP Page
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Fri, 28 Apr 2006 10:49:38 -0500
ste wrote:
"Jerry Stuckle" <jstucklex@xxxxxxxxxxxxx> wrote in message news:G5udneifg5pfZ8zZnZ2dnUVZ_tGdnZ2d@xxxxxxxxxxxxxx
<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@xxxxxxxxxxxxx
==================
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@xxxxxxxxxxxxx
==================
.
- References:
- Re: Problems Creating the Code to Open Images Within a Template PHP Page
- From: Jerry Stuckle
- Re: Problems Creating the Code to Open Images Within a Template PHP Page
- Prev by Date: Re: Warning: ereg(): REG_BADBR
- Next by Date: Re: Problem with require() and script under public_html
- Previous by thread: Re: Problems Creating the Code to Open Images Within a Template PHP Page
- Next by thread: Re: Problems Creating the Code to Open Images Within a Template PHP Page
- Index(es):
Relevant Pages
|