MySQL reconnect?

Back to PHP-IRC Support

Page: 1  
From User Message Body
Farjad
Post #517
Member
Date: 3:45 pm, May 13 2007
Posts: 8


Hello,

I was wondering how do I reconnect to the mysql. If I try a trigger mysql-related I get this message after a few hours "MySQL server has gone away." I found $bot->connectToDatabase($bot) but I couldn't figure out how to use it.

Regards,
Farjad

Mad_Clog
Post #524
user avatar
Member
Date: 7:27 am, May 22 2007
Posts: 176


in databases/mysql.php change mysql_connect(...) to mysql_pconnect(...), that should solve your problem

Farjad
Post #525
Member
Date: 8:06 pm, May 23 2007
Posts: 8


I get the following error after 12 hours of no usage: "DB ERROR: MySQL server has gone away"

Mad_Clog
Post #526
user avatar
Member
Date: 8:40 pm, May 23 2007
Posts: 176


even after you switched from mysql_connect to mysql_pconnect ?
Mind you that you will need to kill and restart the bot as this most likely a core adjustment.

Farjad
Post #527
Member
Date: 6:13 pm, May 26 2007
Posts: 8


Yes I do know that, I still get the error.

Mad_Clog
Post #530
user avatar
Member
Date: 10:26 am, May 30 2007
Posts: 176


A "dirty" work-around could be done by making a timer which does a simple SQL query each X minutes/hours.
This would most likely solve the problem and wouldn't be to much extra load on your bot / mysql server either.

dracozny
Post #945
Member
Date: 5:59 am, Feb 24 2009
Posts: 30


was thinking this would be a slightly less dirty hack. although I am still poking through the main code to determine where to put it....
http://us.php.net/manual/en/function.mysql-ping.php#68526

Manick
Post #948
user avatar
Admin
Date: 12:39 am, Mar 7 2009
Posts: 223


http://www.phpbots.org/mysql.txt
?

--Manick
PHP-IRC Developer
Mad_Clog
Post #949
user avatar
Member
Date: 1:30 pm, Mar 7 2009
Posts: 176


Wouldn't that reconnect if the query fails due to bad syntax as well?
Might be better to check the error code/message.

Manick
Post #950
user avatar
Admin
Date: 5:47 am, Mar 10 2009
Posts: 223


I suppose, but i would assume that you'd work that out before using it long term ...

--Manick
PHP-IRC Developer
   

  Pages (2) [ 1 2 ] Next Page

Back to PHP-IRC Support