ID: 38557 User updated by: tarek at alnhr dot com Reported By: tarek at alnhr dot com -Status: Feedback +Status: Open Bug Type: MySQLi related Operating System: Linux, Unix, Windows PHP Version: 5.1.5 New Comment:
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; ?> Previous Comments: ------------------------------------------------------------------------ [2006-08-23 06:10:20] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2006-08-23 05:08:08] tarek at alnhr dot com I've decided to take rid of the "MySQL server has gone away" error in my scripts forever since i believed time before that the problem is occuring when the mysqli_multi_query function is called in PHP. Today i have made a test to get sure of the exact problem. when i removed the mysqli_multi_query function and replaced every query in the function to a mysqli_query function the error disappeared completely. Tested PHP Versions: 5.1.4, 5.1.5 Tested MySQL Versions: 4.1.19-standard, 4.1.21-standard, 5.0.22-community-nt-log ------------------------------------------------------------------------ [2006-08-23 03:59:35] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38557&edit=1