Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your sql query probably exceeds the <a href="http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_allowed_packet" rel="nofollow noreferrer">max_allowed_packet</a> size in which case the server will disconnect.<br> You might be interested in <a href="http://php.net/mysqli-stmt.send-long-data" rel="nofollow noreferrer">mysqli_stmt::send_long_data</a> which allows you to send parameters longer than max_allowed_packet in chunks. </p> <p>Update: "How can i change it? Is using mysqli is the only option?"<br> Afaik the value can't be altered on a per-session base, i.e. if you cannot change the server configuration (my.cnf or startup parameters) the value will be read-only. edit: As the comment suggests you can change the global value of the mysql server after it has been started if you have <a href="http://dev.mysql.com/doc/refman/5.0/en/privileges-provided.html#priv_super" rel="nofollow noreferrer">the proper permissions</a>. PDO/PDO_MYSQL (as of phpversion 5.3.0) doesn't <i>seem</i> to support send_long_data, but I'm not sure about that either. That would leave <a href="http://php.net/mysqli" rel="nofollow noreferrer">mysqli</a> as the only option. I've recently noticed that <a href="https://stackoverflow.com/users/149111/wez-furlong">Wez Furlong</a> joined stack overflow. Since he is one of the authors of the PDO implementation he might know (though he did not write the pdo_<i>mysql</i> module).</p> <p>(Completely untested and ugly) example</p> <pre><code>// $mysqli = new mysqli(.... $fp = fopen($_FILES['binFile']['tmp_name'], 'rb') or die('!fopen'); //$result = $mysqli-&gt;query('SELECT @@max_allowed_packet') or die($mysqli-&gt;error); //$chunkSize = $result-&gt;fetch_all(); //$chunkSize = $maxsize[0][0]; $chunkSize = 262144; // 256k chunks $stmt = $mysqli-&gt;prepare('INSERT INTO foo (desc, bindata) VALUES (?,?)') or die($mysqli-&gt;error); // silently truncate the description to 8k $desc = 8192 &lt; strlen($_POST['txtDescription']) ? $_POST['txtDescription'] : substr($_POST['txtDescription'], 0, 8192); $stmt-&gt;bind_param('sb', $desc, null); while(!feof($fp)) { $chunk = fread($fp, $chunkSize); $stmt-&gt;send_long_data(1, $chunk) or die('!send_long_data.'.$stmt-&gt;error); } $result = $stmt-&gt;execute(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload