944,098 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 140069
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Feb 20th, 2006
0

How insert image into mysql database and retrieve

Expand Post »
Good day everyone! Anybody could give me script for uploading or inserting image into database and how to retrieve it and print it to browser

Any help would be appreciated.

Thank you in advance.

roland
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
rcasinillo_s is offline Offline
29 posts
since Jan 2006
Feb 20th, 2006
1

Re: How insert image into mysql database and retrieve

Are you sure you really want to do that? I think that for most applications you will be better off storing the image in a folder on your webserver and adding the location/details of the image to the database.
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Feb 20th, 2006
0

Re: How insert image into mysql database and retrieve

Quote originally posted by DanceInstructor ...
Are you sure you really want to do that? I think that for most applications you will be better off storing the image in a folder on your webserver and adding the location/details of the image to the database.
Okey, thinks for your advice, but how can I do that, are there any configuration to be done in the server, could you give me a script for this?

Thank you.

Roland
Reputation Points: 10
Solved Threads: 0
Light Poster
rcasinillo_s is offline Offline
29 posts
since Jan 2006
Feb 20th, 2006
0

Re: How insert image into mysql database and retrieve

I haven't tried this myself, but there is a brief tutorial here:

http://hockinson.com/index.php?s=37

Good luck.
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Apr 9th, 2006
0

Re: How insert image into mysql database and retrieve

If you do decide you want to store the image in a database (there are circumstances) then use a blob datatype.
Reputation Points: 66
Solved Threads: 3
Junior Poster
liliafan is offline Offline
117 posts
since Apr 2004
Apr 15th, 2006
0

Re: How insert image into mysql database and retrieve

I will agree that it is rare that you would want to do that outside of a data hosting site like that. Otherwise you can just store the url and output it however you want by calling it with php and tellting using the following code

echo '<img src ="'.$imgurl.'">';

That will output it as the image itself. Naturally you can add the formating to it. But I find that method INCREADIBY effective.
Reputation Points: 10
Solved Threads: 3
Light Poster
DGStudios is offline Offline
31 posts
since Mar 2006
Apr 15th, 2006
0

Re: How insert image into mysql database and retrieve

hey guys
i have problem somehow similtar to this, how to insert colored, formated text in db and retrieve it.
when i play with the font or anything of the text throught html editor, the text is not saved in db.

the text attribute is empty, what should i write as a script.

thanks

sam
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
web_developer is offline Offline
84 posts
since Mar 2006
Apr 15th, 2006
0

Re: How insert image into mysql database and retrieve

I store things in it using full text

I store it using a variable like so

$value = '<b><center><fontcolor= "blue">This is the formated text</b></center></font>';
$query = "instert into table ('$value')";
mysql_query($query);


I use formated text alot for my forum.

Also it is possible to simply output it the text using concatenated strings with php. Its up to what you're using the text for.
Reputation Points: 10
Solved Threads: 3
Light Poster
DGStudios is offline Offline
31 posts
since Mar 2006
Oct 19th, 2006
0

Re: How insert image into mysql database and retrieve

Click to Expand / Collapse  Quote originally posted by DGStudios ...
I store things in it using full text

I store it using a variable like so

$value = '<b><center><fontcolor= "blue">This is the formated text</b></center></font>';
$query = "instert into table ('$value')";
mysql_query($query);


I use formated text alot for my forum.

Also it is possible to simply output it the text using concatenated strings with php. Its up to what you're using the text for.
This is one way, however you will be unable to use this value in another place with another color settings. Instead I would recommend you store plain text data into your database and use some simple CSS rules where you need the text to be in different color.
You can make the following:
1. Store value $formatted_text = This is the text to be returned in red.
2. Retrieve it in your php page like this: [php]echo '<p style="color: red">'.$formatted_text.'</p>'; [/php]and you will get it right

if you want you can use a class for this statement and add a lot of other formatting stored in an external file.

In case however you have some text and you want to store only one word with formatting, you better do the following:

[php] $formatted_text = 'This is the text with <span style="color: red;">red words</span> in the middle.';[/php]

When you retrieve it in your php like this:

[php]echo '<p>'.$formatted_text.'</p>';[/php]

you will have a paragraph with "red words" being the only red words inside the text.

If you are not familiar with CSS go to http://www.w3schools.com/ and learn it for free from the W3C. Good luck!
Last edited by Rhyan; Oct 19th, 2006 at 10:10 am. Reason: A bit of additional info added
Reputation Points: 21
Solved Threads: 26
Posting Whiz in Training
Rhyan is offline Offline
240 posts
since Oct 2006
Oct 28th, 2006
0

Re: How insert image into mysql database and retrieve

All u do is, use ASP. The database that I've chosen is Microsoft Access database. I could have explained it on Microsoft SQL server but I chose Access because it is inexpensive and widely available. Transition form Access to SQL Server is painless.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
remiremi is offline Offline
10 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Cannot connect to MySQL from PHP. No error message is displayed
Next Thread in PHP Forum Timeline: how to make a chat room without using file or table





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC