Creating Blobs

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
James138
Forum Newbie
Posts: 18
Joined: Thu Feb 05, 2004 1:41 pm

Creating Blobs

Post by James138 »

Hi,
Im trying to get my site to retrieve pictures from the database. Ive been told the picture has to be named as a BLOB. I have since done this. But how do i add pictures to this field within mysql? Because I dont know which folder the images should be stored in at the moment:?

Cheers
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

$sql = "SELECT * FROM table";
$result = mysql_query($sql) or die(mysql_error());

if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
echo "<img src='".$row['pic']."'>";

etc, etc...

Hope that helps!

Regards


Joe 8)
James138
Forum Newbie
Posts: 18
Joined: Thu Feb 05, 2004 1:41 pm

Post by James138 »

Thanks! :D
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

No problem!
James138
Forum Newbie
Posts: 18
Joined: Thu Feb 05, 2004 1:41 pm

Post by James138 »

Hi,
im having a slight problem in the fact that when i call up the picture it is just displaying a load of jumbled up text. has anyone got any ides why?

Regards
James
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

James, read this tutorial:
http://www.phpbuilder.com/columns/florian19991014.php3

This is what I learned from for storing images as blobs in a db.
James138
Forum Newbie
Posts: 18
Joined: Thu Feb 05, 2004 1:41 pm

Post by James138 »

Hi,
I have created a blob for my picture within my database, but the picture is appearing as alot of scrambled text. Any ideas why this is happening? :?
Post Reply