store display LONGBLOB; mysql

Problems with the Windows version of XAMPP, questions, comments, and anything related.

store display LONGBLOB; mysql

Postby alicemcline » 21. August 2009 09:09

hi
i am experiencing strange problem while trying to upload images into mysql LONGBLOB field.. only 255 characters are getting stored and displayed and hence, image is not displayed.. :(

Following is code which i am using for storing icon..
Code: Select all
echo 'Updating Icon..<br/>';
$fname = $_FILES['icon']['tmp_name'];
$ftype = $_FILES['icon']['type'];
$fsize = $_FILES['icon']['size'];
                     
$fp = fopen($fname, 'rb');
$data = addslashes(fread($fp, $fsize));
fclose($fp);

mysql_query("update mytable set icontype = '" . $ftype . "', icon = '" . $data . "' where entity = 'myentity';", $con);
if (mysql_errno())
   die (mysql_error());
                     
unlink($fname);


Following is the code i am using for displaying LONGBLOB
Code: Select all
$iconResult = mysql_query("select icon, icontype from mytable where entity= 'myentity';");
$iconRow = mysql_fetch_assoc($iconResult);
header('Content-Type: ' . $iconRow['icontype'] . "\n");
//header('Content-length: ' . strlen($iconRow['icon']) . "\n");
print $iconRow['icon'];


please tell me what mistake i am making, and how to fix this problem..

thanks alot..
alicemcline
 
Posts: 10
Joined: 10. July 2009 06:56

Re: store display LONGBLOB; mysql

Postby alicemcline » 21. August 2009 10:46

any ideas regarding what's wrong? any configuration file?
alicemcline
 
Posts: 10
Joined: 10. July 2009 06:56

Re: store display LONGBLOB; mysql

Postby Wiedmann » 21. August 2009 13:24

Hm, with my own testscript that's working without problems...

only 255 characters are getting stored

Maybe the field "icon" in the table "mytable" in your selected db does not have the type "longblob"? Or you have 255 in "$_FILES['icon']['size']"?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: store display LONGBLOB; mysql

Postby alicemcline » 21. August 2009 14:22

Thanks for the reply & solution Wiedmann.. you are genius.. :)

mistake was in that table, icon was set to varchar(255) (hmm i mistakenly editted icon instead of another field last time..)
alicemcline
 
Posts: 10
Joined: 10. July 2009 06:56


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 67 guests