Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-21-2007, 02:22 PM   PM User | #1
philmarsay
New to the CF scene

 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
philmarsay is an unknown quantity at this point
Unhappy Unable to add large BLOBS (>10mb) to MySQL DB

I have got a real problem... I have a database system (MySQL) which has a front-end written in PHP.

One of the functions of the front-end is to allow file-upload into the MySQL database, as BLOBS.

I seem to have hit some unpassable limit of approximate 10mb (9mb works, 13 mb fails), of the files that I can get into the database.

I have upped the MAX_PACKET_SIZE in MySQL, and the wait timeout, I have upped the max execution, max input, and memory limits of PHP, all to no avail.

The field in the database is a LONGBLOB, so should be OK.

Can anyone pleeeease tell me that I am missing something obvious somewhere. I understand MySQL is supposed to be handle, theoretically BLOB sizes of up to 2 gig!

Here is the snippet of code that does the uploading... I know this code works, as it works with smaller files...(up to approx 9mb)

$attsql = "insert into attachments values(";
$attsql .= $current_id.",'".$filename."','".$description."','".$filetype."','".$filesize."','".$data."')";
mysql_connect("host", "user", "password");
mysql_select_db("database");
mysql_query($attsql);

If I output the $data to screen, it all seems to be there, but I think MySQL is just plain rejecting the query when the BLOB is big, as nothing is being inserted into the database. The PHP process runs, sends the query to MySQL, and, from that point, nothing happens. Thats how it seems to be.

I can't help thinking this is just a configuration of MySQL that I have not quite gotten right, but I sure can't find it!!

I am using PHP4 and MySQL 4.1

Please help, I'm losing sleep over it!!!!
philmarsay is offline   Reply With Quote
Old 03-21-2007, 04:07 PM   PM User | #2
CFMaBiSmAd
Senior Coder

 
CFMaBiSmAd's Avatar
 
Join Date: Oct 2006
Location: Denver, Colorado USA
Posts: 2,744
Thanks: 2
Thanked 256 Times in 248 Posts
CFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the rough
It is likely that the upload is failing due to one of the limits being reached. Do you have error checking in your code to insure that the upload is successful, before you even get to the point to trying to put it into your database?

Check - $_FILES['your_field_name']['error']

Quote:
UPLOAD_ERR_OK
Value: 0; There is no error, the file uploaded with success.

UPLOAD_ERR_INI_SIZE
Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.

UPLOAD_ERR_FORM_SIZE
Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.

UPLOAD_ERR_PARTIAL
Value: 3; The uploaded file was only partially uploaded.

UPLOAD_ERR_NO_FILE
Value: 4; No file was uploaded.

UPLOAD_ERR_NO_TMP_DIR
Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.

UPLOAD_ERR_CANT_WRITE
Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.

UPLOAD_ERR_EXTENSION
Value: 8; File upload stopped by extension. Introduced in PHP 5.2.0.
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
CFMaBiSmAd is online now   Reply With Quote
Old 03-21-2007, 07:50 PM   PM User | #3
philmarsay
New to the CF scene

 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
philmarsay is an unknown quantity at this point
thanks, its not the upload thats the problem. The current test I am doing is not even uploading the file - just picking it from the filesystem.

However, I think all this is in vain.

Whilst it would be nice to have all these things stored in the database, I am beginning to think it's not the way and I should just be storing them in the filesystem with a link stored in the system.
philmarsay is offline   Reply With Quote
Old 03-21-2007, 08:24 PM   PM User | #4
CFMaBiSmAd
Senior Coder

 
CFMaBiSmAd's Avatar
 
Join Date: Oct 2006
Location: Denver, Colorado USA
Posts: 2,744
Thanks: 2
Thanked 256 Times in 248 Posts
CFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the rough
So, if you are directly reading a file and storing it in the DB, putting a little error checking and reporting on your mysql function calls will probably give you some information as to where the problem is:

Change this -
PHP Code:
mysql_query($attsql); 
To this -
PHP Code:
mysql_query($attsql) or die('The INSERT query failed: ' mysql_error()); 
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
CFMaBiSmAd is online now   Reply With Quote
Old 03-22-2007, 01:31 AM   PM User | #5
philmarsay
New to the CF scene

 
Join Date: Mar 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
philmarsay is an unknown quantity at this point
thanks for the tip.

I had already tried that, and bizarrely it just returned nothing. Maybe I did something wrong, I dunno.

Never mind, I'm going to go down the route of storing the files in the file system. I can only foresee other problems down the line with big files stored in the database.

Is silly that in these days and times, this isn't a simple function, requirement even for database back-ends. Never mind!

Phil
philmarsay is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:45 PM.


Advertisement
Log in to turn off these ads.