Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 29th, 2005, 10:14 AM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Working with Images Issue

Hello
Ok, before I get seriously flamed for this, I have posted this question in another forum on this site and haven't received any response, tried posting it on MySQL without success either.

I have looked through the sections and pages of this site and haven't been able to find "exactly" the help I need.

I want to create an online photo database, what I haven't been able to figure out is how to make an image load into the users web browser when the page is accessed.

When the user accesses the page, I want the photo and text information about that photo to load into the browser. "I want the photo itself and Not a link to the photo to load into the browser".

I have read that it's better to store your photos in a file folder on your server and to use PHP/MYsql to access them that way. Great This is the way I want to solve this issue

However I don't have a clue how to do this.
I can get any of the text records to display in the browser and scroll through each record, one at a time which is what I want Except no accompanying photo.

I have read about using a BLOB field in MySQL or using a reference path (URL or hyperlink) but haven't been able to make these work either. When I tried placing the images as a BLOB field in MySQL the output to the browser was code??? and I don't want a link to the photo

I hope I have explained this issue well enough for it to make since, I know I can't be the only one who has done this or wants to set up a database like this.

Please help
Thanks and be blessed
Capt D

 
Old January 30th, 2005, 10:10 AM
Authorized User
 
Join Date: Jul 2004
Posts: 79
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to rajuru Send a message via Yahoo to rajuru
Default

it will help for us if u write concise form

anyway, so far I understood, you can see the link that you stored into your database. Am I right.
If u can store image link & retrieve it from your database u r almost done.

suppose the link that u retrieve from database is
$imagepath="images/1.jpg"

now u wirte
echo "<img src='".$imagepath."'>";

if I didn't understand ur problem pls. perdon me.

Best Regard:
Md. Zakir Hossain (Raju)
www.rubd.net
www.xenex.rubd.net
www.forum.rubd.net
 
Old January 30th, 2005, 02:00 PM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for responding and I Apologize that I wasn't clear on the help I needed.

I do not know know how to store a link in my database. But, I do know some PHP and MySQL I have learned how to retrieve text data only from a database.

I do somewhat understand the PHP code you posted and how it could be used to retrieve an image.

So could you please tell me how to store an image link in MySQL and a PHP code example of how to retrieve the image

Thank you so much for your help so far

Cpt. D

 
Old January 30th, 2005, 10:21 PM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if you know the location of where the images are being stored you can always use a static variable value. For example, if your images were in the "images" folder under root, you could have something like this:

$loc = "/images/";

then get the picture name from the form or whatever means you are getting the picture from. If it is from a form field, you could concat $loc like this:

$loc .= $_POST['imagename'];
$loc .= ".jpg";

and bingo, you have $loc storing the location of your image. After this, you can just store this in the database and retreive by Rajuru's method.


----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
 
Old January 31st, 2005, 12:27 AM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you saying to store

$loc = "/images/";
as a record in the database?

I know my table example below is horrible but it's the best I can do here. Is this what you mean by using $loc = "images/";




[u]ID | Name | location | F-stop | image</u>
   1 | Dog | USA | 2.4 |$loc = "/images/";

just a little more help,,, I have set up Apache, PHP and MySQL on my PC and can store everything under my "htdocs" folder

But how do you make sure the right photo goes with the right record, there has to be a way to use the ID key

dan
 
Old January 31st, 2005, 02:25 AM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

$loc is the variable that holds the location of the image. it is in the image folder under the current directory, you can use the example above. If not, then write down the path to your image....
Someone experienced in storing images might give you better solutions.

ID | Name | location | F-stop | image
   1 | Dog | USA | 2.4 |/images/;

----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
 
Old January 31st, 2005, 04:49 PM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well,
I appreciate both of you trying help but, I can't figure it out.
It's very frustrating to have come so close and not be able to complete this project.

Like I said my database has about 3000 records in it and I can extract any of the text that I want but haven't been able to link, store or Whatever to get a picture to display.

I have my own web server with about 25 sites or so on it and really wanted to start on a personal project for myself.

I have been through some online classes on PHP and MySQL and even purcahased/downloaded a few books but None of them deal with this topic.

I would hire someone to either tutor me or write this entire section of code for me but, I live in Jackson, Mississippi and no one around here even knows what the heck I'm talkin about when I mention PHP or MySQL.

Again thanks for your help
Cpt D






Similar Threads
Thread Thread Starter Forum Replies Last Post
Refresh images issue in FireFox AbrarNazeer Javascript How-To 1 March 24th, 2008 08:24 AM
Working with TIFF images Freedolen Perl 3 March 16th, 2007 10:55 AM
Php code to put&get images from mysql not working! angelbeans PHP Databases 1 September 8th, 2006 12:44 PM
Working with images Pallav Servlets 6 September 24th, 2004 12:51 PM
GDI+ - Issue Resizing images Hubman VS.NET 2002/2003 2 April 16th, 2004 08:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.