store an image url in mysql, and display the image with mysq

images php coding issues or problems here.

Moderators: macek, egami, gesf

teahou
New php-forum User
New php-forum User
Posts: 1
Joined: Sun Jul 24, 2011 8:17 am

store an image url in mysql, and display the image with mysq

Postby teahou » Sun Jul 24, 2011 8:29 am

Hello. I am new to PHP. I am storing some images in Amazon AWS that will be accessible through a URL. I need to store the URL in a MySQL database, then select and display the individual images with a PHP script.

I imagine the insert script to be something like:

Code: Select all

 $url = "blah.com/myfolder/images01.jpg";

$query = "INSERT INTO images VALUES (NULL, $url);

$result = mysql_query($query);

print "Image URL inserted, thank you."


Then to retrieve the url and display the image, is I believe where the trouble is. I have:

[code]
$query = mysql_query("SELECT * FROM images_test WHERE pid=3");
$row = mysql_fetch_array($query);
$content = $row['image'];

header('Content-type: image/jpg');

echo $content;

All I get is a notice saying the image can not be displayed because it contains errors.

Any hints or a good tutorial link would be great, thanks!

NigelRen
php-forum Active User
php-forum Active User
Posts: 450
Joined: Fri Aug 05, 2011 9:53 am

Re: store an image url in mysql, and display the image with

Postby NigelRen » Fri Aug 05, 2011 9:55 am

Hiya
Not sure if this is the problem - but the URL your using isn't complete.

I think it should be something like

Code: Select all

$url = "http://www.blah.com/myfolder/images01.jpg";

jimmy19880
New php-forum User
New php-forum User
Posts: 2
Joined: Sun Oct 16, 2011 6:24 pm

Re: store an image url in mysql, and display the image with

Postby jimmy19880 » Sun Oct 16, 2011 6:31 pm

Nice to meet you!I want to tell you a funny story:George comes from school on the first of September. "George, how did you like your new teacher?" asked his mother. "I didn't like her, Mother, because she said that three and three were six and then she said that two and four were six too....."





_________________________________________
buy wow gold|Runescape Gold|Buy Aion Kinah|Buy Maple Story Mesos


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 0 guests

cron