You are here: Re: Problems Creating the Code to Open Images Within a Template PHP Page « PHP Programming Language « IT news, forums, messages
Re: Problems Creating the Code to Open Images Within a Template PHP Page

Posted by ste on 04/28/06 19:43

"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:rpSdnaLkQpsIpM_ZRVn-rw@comcast.com...
<snip>
> 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
> ==================


Hi Jerry,

There is a field called imagelocation in my database, so this is okay.

I entered your code above, and like the other piece of code I had, it
displayed nothing, besides some HTML tags <pre></pre>.

This made me examine the actual query again and made me wonder if anything
was being passed from the URL at all. I've got a PHP and MySQL book dor
dummies (I couldn't find myself a more basic one, so had to settle for this!
:-)), so out of interest and by chance, I looked up the $_POST command. In
the same chapter, I came across the $_GET command too, and although I still
don't know what they mean, the following sentence rang out to me: 'Contains
all the variables passed from a previous page as part of the URL.' Of
course, that still means nothing, except for the bit about the URL.

So I changed $_POST to $_GET, and it worked! I'm amazed, but I wouldn't
have even got this far without your help on this, so thank you. I'm working
by trial and error it has to be said, and I've lost count of the number of
times I've uploaded and tested php pages with my FTP browser recently! :-)

For info, the following piece of code is the code that works:

<?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 = \"{$_GET['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\" />";
?>

I've even tested it by adding in other fields from the database, and that
works great too!

If you have any suggestions on how any of the above can be tidied up, please
don't hesitate to let me know, though it works so that's the main thing.

Finally, do let me know if you know of any good onlie php/mysql tutorials
for creating image galleries and the like.

Thanks again,

Ste

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация