strange MySQL connect problem - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: strange MySQL connect problem (
/showthread.php?tid=274824)
strange MySQL connect problem -
BritishBoy - 07.08.2011
My server goes crazy if it can't connect to the db.. It have to print one time "** Server couldn't connect to the database, try again.. **" that, and one time this ** Server couldn't connect to the database, server shutdown.**,
(see the log below)
Код:
stock MySQLConnect()
{
mysql_debug(1);
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
if(mysql_ping() == -1) return CheckMySQL();
return 1;
}
stock CheckMySQL()
{
if(mysql_ping() == -1)
{
print("** Server couldn't connect to the database, try again.. **");
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
if(mysql_ping() == -1)
{
print("** Server couldn't connect to the database, server shutdown.**");
return SendRconCommand("exit");
}
}
return 1;
}
Код:
[14:26:25] ** Server couldn't connect to the database, try again.. **
[14:26:26] ** Server couldn't connect to the database, server shutdown.**
[14:26:26] ** Server couldn't connect to the database, try again.. **
[14:26:27] ** Server couldn't connect to the database, server shutdown.**
[14:26:27] ** Server couldn't connect to the database, try again.. **
[14:26:28] ** Server couldn't connect to the database, server shutdown.**
[14:26:28] ** Server couldn't connect to the database, try again.. **
[14:26:29] ** Server couldn't connect to the database, server shutdown.**
[14:26:30] ** Server couldn't connect to the database, try again.. **
[14:26:31] ** Server couldn't connect to the database, server shutdown.**
[14:26:31] ** Server couldn't connect to the database, try again.. **
[14:26:32] ** Server couldn't connect to the database, server shutdown.**
[14:26:32] ** Server couldn't connect to the database, try again.. **
[14:26:33] ** Server couldn't connect to the database, server shutdown.**
[14:26:33] ** Server couldn't connect to the database, try again.. **
[14:26:34] ** Server couldn't connect to the database, server shutdown.**
[14:26:34] ** Server couldn't connect to the database, try again.. **
[14:26:35] ** Server couldn't connect to the database, server shutdown.**
[14:26:35] ** Server couldn't connect to the database, try again.. **
[14:26:36] ** Server couldn't connect to the database, server shutdown.**
[14:26:36] ** Server couldn't connect to the database, try again.. **
[14:26:37] ** Server couldn't connect to the database, server shutdown.**
[14:26:37] ** Server couldn't connect to the database, try again.. **
[14:26:38] ** Server couldn't connect to the database, server shutdown.**
[14:26:38]
[14:26:38] _______________________________________
[14:26:38][*] Server started[*]
[14:26:38] _______________________________________
[14:26:38]
[14:26:38] Number of vehicle models: 13
[14:26:38] --- Server Shutting Down.
Re: strange MySQL connect problem -
iJumbo - 07.08.2011
try
pawn Код:
stock CheckMySQL(sqlhost[], sqluser[], sqlpass[], sqldb[])
{
print("** Trying to connect to mysql server **");
mysql_connect(sqlhost, sqluser, sqldb, sqlpass);
if(mysql_ping()==1)
{
print("** Server connected **");
return 1;
}
else
{
print("** Server couldn't connect to the database, try again.. **");
mysql_connect(sqlhost, sqluser, sqldb, sqlpass);
if(mysql_ping()==1)
{
print("** Server connected **");
return 1;
}
else
{
print("** Server couldn't connect to the database, server shutdown.**");
SendRconCommand("exit");
return 0;
}
}
}
Re: strange MySQL connect problem -
BritishBoy - 07.08.2011
Problem resolved, thx.