MySQLConnect() - 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: MySQLConnect() (
/showthread.php?tid=250781)
MySQLConnect() -
BritishBoy - 24.04.2011
Hi,
Why isn't this working?
I turn my WAMP MySQL off to test it, but the text won't be printed and the server doesn't close.
Код:
stock MySQLConnect()
{
mysql_debug(1);
if(!mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS))
{
print("Server failed to connect to MySQL!");
SendRconCommand("exit");
}
return 0;
}
Re: MySQLConnect() -
playbox12 - 24.04.2011
Because "mysql_connect" returns the connection handle instead of 'fail' or 'success'
Instead you could do:
pawn Код:
if(mysql_ping()==-1)
{
print("Server failed to connect to MySQL!");
SendRconCommand("exit");
}
Re: MySQLConnect() -
BritishBoy - 24.04.2011
Thanks for answering!
Like this?
Код:
stock MySQLConnect()
{
mysql_debug(1);
if(!mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS))
{
if(mysql_ping()==-1)
{
print("Server failed to connect to MySQL!");
SendRconCommand("exit");
}
}
return 0;
}
It doesn't work
Re: MySQLConnect() -
[NoV]LaZ - 24.04.2011
pawn Код:
stock MySQLConnect()
{
mysql_debug(1);
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
if (mysql_ping()) == -1)
{
print("Server failed to connect to MySQL!");
SendRconCommand("exit");
}
else
{
print("Connection successful\nGood day");
}
}
Re: MySQLConnect() -
BritishBoy - 24.04.2011
It works, thanks man!