Hello
I have a connection to mysql as
$ndb = mysql_connect($host,$dbuser,$dbpass, TRUE) or die ("Database Connection Error<br>");
There are many php function tah can be take many time, so after this I check if connection is live with
if (!$ndb)
..
reconect code
..
Problem is that $ndb is always TRUE also when is timeout (by wait_timeout on my.cnf)
So, how check if connection is live and not timeout ?
Thanks
mysql_connect and timeout
Moderator: General Moderators
Re: mysql_connect and timeout
Once you have done $ndb = mysql_connect(...), later on $ndb won't suddenly change by itself if you get disconnected.
You can try mysql_ping, or alternatively try connecting with mysql_pconnect instead of mysql_connect.
You can try mysql_ping, or alternatively try connecting with mysql_pconnect instead of mysql_connect.
Re: mysql_connect and timeout
HiApollo wrote:Once you have done $ndb = mysql_connect(...), later on $ndb won't suddenly change by itself if you get disconnected.
You can try mysql_ping, or alternatively try connecting with mysql_pconnect instead of mysql_connect.
mysql_ping() seems the work way
thanks