Re: Problems Creating the Code to Open Images Within a Template PHP Page



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
==================
.



Relevant Pages

  • Re: Getting ID from a presented table
    ... Jerry Stuckle ... JDS Computer Training Corp. ... PHP echo statement instead. ... I do not know how to do that in HTML. ...
    (comp.lang.php)
  • Re: Getting ID from a presented table
    ... Jerry Stuckle ... JDS Computer Training Corp. ... Same idea - just generated with a PHP echo statement instead. ... I do not know how to do that in HTML. ...
    (comp.lang.php)
  • Re: Getting ID from a presented table
    ... Jerry Stuckle ... JDS Computer Training Corp. ... PHP echo statement instead. ... I do not know how to do that in HTML. ...
    (comp.lang.php)
  • Re: Getting ID from a presented table
    ... Jerry Stuckle ... JDS Computer Training Corp. ... Same idea - just generated with a PHP echo statement instead. ... I do not know how to do that in HTML. ...
    (comp.lang.php)
  • Re: Gallery Pagination Result Problem
    ... Jerry Stuckle ... JDS Computer Training Corp. ... To add to this, I've just noticed that when I load the landscape gallery, not only does it display all images now instead of just the landscape images, but if I click the paginated result for page 2, it changes the page title back to just Gallery, instead of the main page of Landscape gallery. ... I've got PHP and My SQL for Dummies, and PHP and MySQL Web Development. ...
    (comp.lang.php)