[BlueG mysql plugin] Check 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: [BlueG mysql plugin] Check connection (
/showthread.php?tid=472038)
[BlueG mysql plugin] Check connection -
xGoldenx - 26.10.2013
Hi. How can I check if the script connected to the database (using mysql_connect)? I would like prevent whole gamemode loading when the connection doesn't work.
Re: [BlueG mysql plugin] Check connection -
x96664 - 26.10.2013
There is mine:
pawn Код:
ConnectMySQL()
{
IMDb = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
if(IMDb && mysql_errno(IMDb) == 0)
{
printf("[MySQL]: Connection to database [%s] successfully established!", SQL_DB);
}
else
{
printf("[MySQL]: Connection to database [%s] failed!", SQL_DB);
}
}
Re: [BlueG mysql plugin] Check connection -
RajatPawar - 26.10.2013
pawn Код:
if(mysql_ping() < 0)
{
print("MYSQL: Server failed to connect.");
SendRconCommand( "exit" );
}