Current location: Hot Scripts Forums » Programming Languages » PHP » inserting images into mysql


inserting images into mysql

Reply
  #1 (permalink)  
Old 11-29-03, 05:19 PM
coatsey coatsey is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Cool inserting images into mysql

I need someassistance or a guidance in some php/mysql coding if there is any body out there.

I am currently designing a database driven website where users log in and out etc. Once logged in there is a form where users can fill out and upload a picture of their car and submit it into a mysql database. First of all how would i go about inserting an image and text into a table into a mysql database. Also once the user has done this i would like them to view what they have just done. How would i go about that?

I know i can pull off a query on text but how can i doit so it can display their picture as well as a description underneath?

And one last thing i am using a dropdown box for people to choose where they live so later i can insert a search query to search for cars in that county. So i am trying to search for a list of cars whichwill be pulled of the mysql database and listed for users to then choose.

I might be asking for too much i know, i have taken this job on as a favour to afriendwho is car mad and we/i thought to give it a go.

Help...

Thanks
Reply With Quote
  #2 (permalink)  
Old 12-01-03, 01:38 PM
jpp's Avatar
jpp jpp is offline
Newbie Coder
 
Join Date: Nov 2003
Location: Arnhem, The Netherlands
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
My choice would be to store the images in a directory, and not in your db. Binary data in your db can slow down the performance. Don't know if u use phpMyAdmin or something like that, it gets real slow when it tries to display binarydata in ascii.
Before storing the image you could rename it to the primary key of your table ($id?), and then in your page all you have to do is:
PHP Code:

echo "<img src=\"imagedirectory/$id.jpg\">"
__________________
<font face="verdana" size="2" color="#000066">
JPP</font><br>
<a href="mailto:jpp@ipportunities.nl"><font face="verdana" size="2" color="#000066">jpp@ipportunities.nl</font></a>
Reply With Quote
  #3 (permalink)  
Old 12-01-03, 06:08 PM
SEATi SEATi is offline
New Member
 
Join Date: Dec 2003
Location: Mexico
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by coatsey
I need someassistance or a guidance in some php/mysql coding if there is any body out there.

I am currently designing a database driven website where users log in and out etc. Once logged in there is a form where users can fill out and upload a picture of their car and submit it into a mysql database. First of all how would i go about inserting an image and text into a table into a mysql database. Also once the user has done this i would like them to view what they have just done. How would i go about that?



Thanks
Just use the BLOB field type, read the temp file generated by the upload, add slashes to it (otherwise it could contain "dangerous" characters) and insert it into the blob field.

To display the image create a php file that sends a Content type header with image/jpeg or gif or whatever you are going to use and "echo" the results.

The other solution (storing them in a directory) is fine, but you would need to make that directory writeable by the webserver, and that can be kinda risky. If you have a nice box to deploy a huge database then go on and use the blob field.
Reply With Quote
  #4 (permalink)  
Old 12-01-03, 07:04 PM
coatsey coatsey is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Adding pics in php

Quote:
Originally Posted by jpp
My choice would be to store the images in a directory, and not in your db. Binary data in your db can slow down the performance. Don't know if u use phpMyAdmin or something like that, it gets real slow when it tries to display binarydata in ascii.
Before storing the image you could rename it to the primary key of your table ($id?), and then in your page all you have to do is:
PHP Code:

echo "<img src=\"imagedirectory/$id.jpg\">"

I have created a registration form for users to insert details of themselves and include a picture of themselve to upload to the server. I have now decided to send my images to a destination file on the server to keep databse activity optimum.

I am stuck though. How can i get my users to register their details aswell as including an image to store in the database. Is this where the id value comes into use. How ould i go about that and also when it comes to retriving the data how would i retrieve the data from the databse as well as the picture and letting all users view this on a web page.

Help.....
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
MySQL LIMIT question corbyboy PHP 1 02-14-04 12:04 AM
great product for dumping/recovering MySQL databases Dave Brown General Advertisements 1 10-03-03 07:40 AM
List images and zip before download jaimexyz Script Requests 0 09-01-03 03:01 PM
Displaying images from MYSQL Soulidified PHP 1 07-22-03 06:01 PM


All times are GMT -5. The time now is 06:03 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.