Page 1 of 1

Problem with inserting BLOB into mysql DB

Posted: Fri Jan 16, 2009 3:53 pm
by cboileau
Here is the snipet of code from the script. The echo on line 3 goes through, so i know the imgdata variable is defined, however it will not insert it into the database.

Code: Select all

$imgurl="http://www.wowarmory.com/wow-icons/_images/43x43/inv_helmet_134.png";
$imgdata=open_page($imgurl,1,2,0,0,0,$postcontent);
echo $imgdata;
mysql_query("Insert into `items` (`icon`) VALUES('$imgdata')");
$findid=mysql_insert_id();
$Select_img=mysql_query("Select * from items where id='$findid'");
$img=mysql_fetch_array($Select_img);
echo "$img[icon]";
If I change it around to be the following, it does the insert however, but obviously only with the word test.

Code: Select all

$imgurl="http://www.wowarmory.com/wow-icons/_images/43x43/inv_helmet_134.png";
$imgdata="test";
mysql_query("Insert into `items` (`icon`) VALUES('$imgdata')");
$findid=mysql_insert_id();
$Select_img=mysql_query("Select * from items where id='$findid'");
$img=mysql_fetch_array($Select_img);
echo "$img[icon]";
Any ideas? Thanks guys

Re: Problem with inserting BLOB into mysql DB

Posted: Fri Jan 16, 2009 5:07 pm
by Burrito
what does open_page() do?

Re: Problem with inserting BLOB into mysql DB

Posted: Fri Jan 16, 2009 6:13 pm
by cboileau
Its a customer function similar to curl, basicly pulls the image data from the file on the website. That function is working fine in this case though, because i can echo its output perfectly, it just wont insert it.

Re: Problem with inserting BLOB into mysql DB

Posted: Fri Jan 16, 2009 6:27 pm
by Burrito
when you say you see its output perfectly, do you mean you see the binary string or you see the image?

I would replace your open_page() function with file_get_contents() to get the binary string of the file and dump that into your database.