php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38557 mysqli_multi_query Causes MySQL server to go away
Submitted: 2006-08-23 03:59 UTC Modified: 2006-08-23 20:51 UTC
From: tarek at alnhr dot com Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.1.5 OS: Linux, Unix, Windows
Private report: No CVE-ID: None
 [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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-23 05:08 UTC] 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 06:10 UTC] georg@php.net
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 20:34 UTC] tarek at alnhr dot com
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;

?>
 [2006-08-23 20:48 UTC] tarek at alnhr dot com
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;

?>
 [2006-08-23 20:51 UTC] tony2001@php.net
Duplicate of bug #37732.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 09:01:29 2024 UTC