|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55741 Warning thrown
Submitted: 2011-09-20 14:47 UTC Modified: 2013-02-18 00:35 UTC
From: patrick_adrichem at hotmail dot com Assigned: mysql (profile)
Status: No Feedback Package: MySQL related
PHP Version: 5.3SVN-2011-09-20 (SVN) OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: patrick_adrichem at hotmail dot com
New email:
PHP Version: OS:


 [2011-09-20 14:47 UTC] patrick_adrichem at hotmail dot com
From manual page:

Mysql_ping is in my vision used to check wether your connection is still alive, by pinging the server since PHP 5.0.38 this function no longer autoreconnects, so its a real "Check if connection is alive" function. However if the connection is not alive it still throws a warning:

mysql_ping(): 8 is not a valid MySQL-Link resource

Which is obvious, because thats why you use this function...

Test script:


$rConnection = mysql_connect("host", "user", "pass") or die("Could not connect");


if (false === mysql_ping($rConnection))
echo "Connection gone";
echo "Connection alive";

Expected result:
Connection gone

Actual result:
mysql_ping(): 8 is not a valid MySQL-Link resource
Connection gone


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-20 14:50 UTC]
-Assigned To: +Assigned To: uw
 [2011-09-20 14:50 UTC]
ulf, plz look at this.
 [2011-10-18 20:16 UTC]
-Status: Assigned +Status: Feedback
 [2011-10-18 20:16 UTC]
I wasn't able to reproduce with 5.3-svn and two builds:
- mysqlnd
- libmysql

Here is my mysqlnd output:
$ ./php -r 'error_reporting(E_ALL);$c=mysql_connect("","root","root");var_dump($c);var_dump(mysql_query("set @@wait_timeout=5",$c));sleep(7);var_dump(mysql_ping($c));'
resource(6) of type (mysql link)

Warning: mysql_ping(): MySQL server has gone away in Command line code on line 1

Here is my libmysql output:
$ ./php -r 'error_reporting(E_ALL);$c=mysql_connect("","root","root");var_dump($c);var_dump(mysql_query("set @@wait_timeout=5",$c));sleep(7);var_dump(mysql_ping($c));'
resource(4) of type (mysql link)

I suspect how it could be shut up, but I can't reproduce it to be able to test it.
 [2011-10-18 20:17 UTC]
-Assigned To: uw +Assigned To: mysql
 [2013-02-18 00:35 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 12:01:29 2024 UTC