Hi guys,

I'm running an UPDATE query on one of my tables and I get an error:

"Got a packet bigger than 'max_allowed_packet' bytes".

I've tried changing the max_allowed_packet by using ini_set() but this failed to work. The field data type is set to longtext and the length of the string i'm trying to insert is 1.6million characters long.

Can anyone please tell me how I can get this damn thing into the database.. it's driving me mad! lol.

Many thanks,

BIOSTALL

    Why do u use ini_set?
    Who said max_allowed_packet is a php configuration? Click on the ini_set to find out more about that function ...

    This need to be set in your mysql server, try google for more about your problem or the install section of this forum.

      max_allowed_packet is a server setting and needs to be set on the mysql server.

      In any case if you're dealing with very large BLOBs / text fields, you should be using prepared statements and streaming the blob in in chunks. I don't know whether this is possible using PHP (It probably isn't possible with the mysql_ functions, only mysqli or PDO).

      http://uk.php.net/manual/en/function.mysqli-stmt-send-long-data.php

      In any case 1.6 megs should not be a problem (maybe it will be up to 3x more if you're using a multibyte character set).

      Look at the server setting and ensure that it's reasonable- I think the default is 16M so should be fine.

      Mark

        Write a Reply...