php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40032 mysql_ping does not reconnect
Submitted: 2007-01-05 14:28 UTC Modified: 2007-01-05 15:28 UTC
From: federico at galassi dot net Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.2.0 OS: Gentoo linux
Private report: No CVE-ID: None
 [2007-01-05 14:28 UTC] federico at galassi dot net
Description:
------------
When mysql server closes the connection, for example because
of wait_timeout configuration parameter, mysql_ping always
returns false and never reconnects to mysql.
Using the link gives "MySQL server has gone away" error.

Reproduce code:
---------------
/*
set wait_timeout = 10 and restart mysql
then run this php script
*/
$db = mysql_connect(...); // succeeds
sleep(15);
while (!mysql_ping($db)) {
   echo "ping failed\n";
}
echo "connected\n";
mysql_close($db);

Expected result:
----------------
loop ends and script prints "connected\n"

Actual result:
--------------
loop never ends

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-05 15:28 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The attempt to re-connect is done by MySQL's ping() command, 
PHP has not influence on whether it works or not. More over, 
the MySQL docs indicate that re-connection is not guaranteed, 
it will merely attempt to do it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 08:01:28 2024 UTC