SA-MP Forums Archive
MySQL Connection - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Connection (/showthread.php?tid=407470)



MySQL Connection - CoaPsyFactor - 13.01.2013

Hello there, I noticed this happened to my SAMP server:

Код:
Error ID: 2006, MySQL server has gone away
As I understood its because SAMP server has disconnected. I also saw some of helps for that but i don't want to use mysql_ping() function because it could cause server freeze. I also made timer every 3 minutes that run some query just to keep connection alive, but still it happened. And to add SAMP server and MySQL server are not on same machine. So I connect to remote server.


Re: MySQL Connection - Scenario - 14.01.2013

Ping the MySQL server from the server you're running SA:MP on. What is the response?


Re: MySQL Connection - meycool - 16.01.2013

IDK WHY but i cant connect to my server bcoz that said ur name registered ,, but i didnt if u can help me thanks
(thats full my sql and u use mysql r5


Re: MySQL Connection - RajatPawar - 16.01.2013

This happened to me. The connection would get alive, and then die for some unknown reason. I found out it was a wrong query doing this.


Re: MySQL Connection - azzerking - 16.01.2013

Make sure you close the mysql connection after you perform a query statment, and also make sure that there are no mistakes in your query's.

Make sure you have an up to date plugin and that you may need to perform a debug test. Meaning for each query "Print" the results and see if any errors come up.

Hope this helps.


Re: MySQL Connection - Sinner - 16.01.2013

Quote:
Originally Posted by azzerking
Посмотреть сообщение
Make sure you close the mysql connection after you perform a query statment
If you do this you'll be in for A LOT of lag. Continuesly connecting and disconnecting to a database is very slow. You only need to connect and disconnect once, which is during OnGameModeInit() and OnGameModeExit().

Check all your queries for mistakes (use mysql_debug(1) to check them), incase you can't find the error and want to brute-force the connection into working you can use something like this in a loop:

pawn Код:
if(!mysql_ping()) {
    mysql_connect();
}