|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-09-02 04:37 UTC] november at netsecuretech dot com
Description:
------------
PHP version : 5.3.0 Windows Binary VC9 x86 Thread Safe (2009-Jun-30 08:52:56)
Mysql version : 5.1.37-community-edition (CentOS 4.7)
I use php CLI SAPI.
PHP cli's default max_execution_time is unlimited.
When I execute php script, mysql connection is lost.
When I use php 5.2.10, mysql query executed well.
What Can I do?
Thank you.
Reproduce code:
---------------
<?php
$db = mysqli_connect('x.x.x.x', 'id', 'pw', 'db');
if (!$db) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
echo date("Y-m-d H:i:s")." => query start...\r\n";
$query = "create table test as select c_ip, count(*) from iis_summary group by c_ip";
mysqli_query($db, $query);
if (mysqli_errno($db) != 0) {
echo mysqli_errno($db)." ".mysqli_error($db)."\r\n";
}
echo date("Y-m-d H:i:s")." => query end...\r\n";
mysqli_close($db);
?>
Expected result:
----------------
During query, mysql connection lost.
PHP Warning: mysqli_query(): MySQL server has gone away in C:\php\Script\mysqli
_test.php on line 14
Actual result:
--------------
C:\php\Script>..\php.exe mysqli_test.php
2009-09-02 13:23:15 => query start...
PHP Warning: mysqli_query(): MySQL server has gone away in C:\php\Script\mysqli
_test.php on line 14
PHP Warning: mysqli_query(): Error reading result set's header in C:\php\Script
\mysqli_test.php on line 14
2006 MySQL server has gone away
2009-09-02 13:24:15 => query end...
C:\php\Script>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 07:00:01 2025 UTC |
I think this problem isn't related to mysql error. I modifyed php.ini. Before : default_socket_timeout = 0 After : default_socket_timeout = -1 I execute php script. Php script was processed successed. Default_socket_timeout influence mysqli connection? I tested below script. If default_socket_timeout is -1, script isn't ended. I think mysqli connection timeout and socket timeout managed separated. thank you. <?php echo 'PHP ' . phpversion() . "\n\n"; echo date('H:i:s ')."Start script\n"; ini_set('default_socket_timeout', 60); echo 'max_execution_time: ' . ini_get('max_execution_time') . "\n"; echo 'default_socket_timeout: ' . ini_get('default_socket_timeout') . "\n"; $mysqli = new mysqli('localhost', 'does', 'not', 'matter', 1); if ($mysqli->connect_error) { echo "GOOD CATCH\n"; } echo date('H:i:s ')."End script\n\n"; echo date('H:i:s ')."Start script\n"; ini_set('default_socket_timeout', -1); echo 'max_execution_time: ' . ini_get('max_execution_time') . "\n"; echo 'default_socket_timeout: ' . ini_get('default_socket_timeout') . "\n"; $mysqli = new mysqli('localhost', 'does', 'not', 'matter', 1); if ($mysqli->connect_error) { echo "GOOD CATCH\n"; } echo date('H:i:s ')."End script\n\n"; ?>