|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-08-23 03:59 UTC] tarek at alnhr dot com
Description: ------------ When using mysqli_multi_query function, the function on some servers always makes an error in the MySQL server (Got an error reading communication packets) and on the other some servers it sometimes makes the error in the MySQL server. If you need more information and need to know how the error occurs exactly i can provide more information. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 05:00:01 2025 UTC |
You can try the following script: <? ## DB Host $dbhost = "localhost"; # DB Username $dbusername = "root"; # DB Password $dbpasswd = ""; ## Making the connection to the MySQL server $link = new mysqli($dbhost, $dbusername, $dbpassword); if (mysqli_connect_errno()){ print "An error occured while connecting to the MySQL server:<br>".mysqli_connect_error(); } ## Generating the error by using mysqli_multi_query $link->multi_query("set character_set_server='cp1256'; set names cp1256;"); ## Try to commit the following line, The "MySQL server has gone away" error will disappear $link->query("SHOW PROCESSLIST"); ## Obtaining the error message if ($link->errno){ print "An error occured while using the database:<br>".$link->error; }else{ print "The query excuted successfully."; } ## Closing the connection to the MySQL server $db_link->close; ?>Please Remove the previous example since the follwing example contains no mistakes in the code: <? ## DB Host $dbhost = "localhost"; ## DB Username $dbusername = "root"; ## DB Password $dbpasswd = ""; ## Making the connection to the MySQL server $db_link = new mysqli($dbhost, $dbusername, $dbpassword); if (mysqli_connect_errno()){ print "An error occured while connecting to the MySQL server:<br>".mysqli_connect_error(); } ## Generating the error by using mysqli_multi_query $db_link->multi_query("set character_set_server='cp1256'; set names cp1256;"); ## Try to commit the following line, The "MySQL server has gone away" error will disappear $db_link->query("SHOW PROCESSLIST"); ## Obtaining the error message if ($db_link->errno){ print "An error occured while using the database:<br>".$db_link->error; }else{ print "The query excuted successfully."; } ## Closing the connection to the MySQL server $db_link->close; ?>