Click to See Complete Forum and Search --> : Php Mysql Blob Problem


gruetztian
04-12-2005, 03:16 AM
hi,
can someone help me please. i try to work with php fileoperations and mysql blob datatypes.
i have a (apache)webserver and a mysql database running on a suse linux system.
my problem is.
if i try to open a file for example test.pdf and its 118 KB large insert it into a table, later read the data from the blob field i only get 64 KB back no matter which size (larger then 64KB).it is a problem with the settings yes?but where is the problem apache (httpd.conf), php or mysql (/etc/my.cnf)?

a code example.
//table has a id and a blob field called data

$query = "INSERT INTO table (data) VALUES (\"".addslashes(fread(fopen("test.pdf","r"),filesize("test.pdf")))."\")";

mysql_query($query,$conn);

//read data

$query = "SELECT data from table WHERE id=1";
$rs = mysql_query($query,$conn);
$row = mysql_fetch_row($rs);

header("Content-Type: application/pdf");
echo $row;

max size of returned data is 64KB

olaf
04-12-2005, 05:15 AM
from the mysql website:

Posted by Mike Dickson on December 10 2004 11:51pm [Delete] [Edit]

Notice the BLOB's max size is only 64K. MySQL's JDBC trunicated my .wav file at 64K w/ no Exception being generated. Look at a bigger BLOB like MEDIUMBLOB.

gruetztian
04-12-2005, 06:07 AM
oh ****, im an idiot or? all i have to do (or i forgot) is to use another datatypes or a large type of blob. ****!thanks olaf. simple! schande!

MEDIUMBLOB maximum length of 16,777,215 (2^24 - 1) characters
LONGBLOB maximum length of 4,294,967,295 or 4GB (2^32 - 1) characters

ok a mediumblob is enought. thanks alot.

olaf
04-12-2005, 06:12 AM
hehe... gern geschehen... :D

gruetztian
04-12-2005, 06:21 AM
auch from germany olaf? eigentlich ist das hier doch eine amerikanische seite oder von amerikanischen betreibern. was spricht man hier, ob man auch einfach immer mal auf deutsch probieren kann? Ich würg mir mit meinem englisch immer total einen ab (macht die sache ja nur unnötig komplizierter).

ok danke nochmal olaf habs geändert and everything is working fine!!!

Stephen Philbin
04-12-2005, 07:15 AM
I'm on exactly the same setup: Suse, apache, mysql :D

I think that you might have a problem at some point with your config of MySQL if the files you're trying to retrieve get too big. You might have to increase some of the query buffers etc in /etc/my.cnf

If you do need to increase them though, make sure you read the manual section about editing my.cnf because it gives some proportions/ratios for other settings. So if you increase one setting, you might have to increase another by the same percentage and so on.

olaf
04-12-2005, 08:33 AM
auch from germany olaf? eigentlich ist das hier doch eine amerikanische seite oder von amerikanischen betreibern. was spricht man hier, ob man auch einfach immer mal auf deutsch probieren kann? Ich würg mir mit meinem englisch immer total einen ab (macht die sache ja nur unnötig komplizierter).

ok danke nochmal olaf habs geändert and everything is working fine!!!
Ja die Welt besteht jedoch nicht nur aus Deutschland... Ich persönlich finde es selbst eher unpraktisch die Posting in deutscher Sprache zu schreiben...(immer wieder umschalten, de > en > nl > ...