Page 2 of 2
myblobs
Posted: Thu May 03, 2007 7:48 am
by metal
yes the blobId is auto_increment
Posted: Thu May 03, 2007 8:12 am
by arturm
mysql is case sensitive so Myblobs myBlobs and myblobs are different tables.
blobs
Posted: Thu May 03, 2007 8:30 am
by metal
I have changed it from myBlobs to myblobs and I am still recieving the message "Could not add file to the database"

Posted: Thu May 03, 2007 9:42 am
by arturm
change your code to:
Code: Select all
mysql_query($dbQuery);
echo mysql_error();
we will see what error do you have
Posted: Thu May 03, 2007 10:22 am
by metal
I typed in the coding and the following message was returned:
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '³Ù0' at line 1"
I am unsure what this means!!!
Posted: Thu May 03, 2007 10:29 am
by arturm
it means that file content breaks mysql query.
To avoid that use base64_encode() function before inserting image to the database and base64_decode() before displaying it on a page.
Posted: Thu May 03, 2007 12:24 pm
by metal
I'm afraid thats abit more technical then I'm used to. Do you mean I should insert base64_encode() function just before the INSERT and base64_decode() in my script at some point after that? Also it is written reports I am adding to my database, would this make it any different than inserting a image?
This is my first attempt with PHP so I still have a mountain to climb with it!!!!
Posted: Thu May 03, 2007 12:52 pm
by arturm
do that:
Code: Select all
$file_contents = base64_encode(file_get_contents($_FILES['fileUpload']['tmp_name']));
and somewhere later in code when you take data from the database and you display your image
instead
you have to do
Code: Select all
echo base64_decode($file_contents);
Posted: Thu May 03, 2007 1:36 pm
by metal
Thank you very much, that has worked. The file size is now showing as 26.0 KB instead of 0KB!! Now all I have to do is figure out how to download it
Thanks again, it has been much appreciated!!