[MySQL] Connection failed ?
#1

Hello. I'm using MySQL Plugin R4 (VS9) by G-sTyLeZzZ (with libmysql.dll too) and having problem with this code:
pawn Код:
public OnGameModeInit()
{
    if (!mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS)) print("ERROR: Failed to connect database!");
    return 1;
}
It doesn't print message if I turn the MySQL server off or change host/user/db/pass to incorrect. The MYSQL_* fields are defined 100% correctly. I've turned on the MySQL debugging, and it works fine (connect successful if everything is correct and mysql server is up, and fail to connect if something is wrong or mysql server is down). Is the above code correct to check the mysql connection success or fail?
Reply
#2

Quote:
Originally Posted by paweltbg94
Посмотреть сообщение
Hello. I'm using MySQL Plugin R4 (VS9) by G-sTyLeZzZ (with libmysql.dll too) and having problem with this code:
pawn Код:
public OnGameModeInit()
{
    if (!mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS)) print("ERROR: Failed to connect database!");
    return 1;
}
It doesn't print message if I turn the MySQL server off or change host/user/db/pass to incorrect. The MYSQL_* fields are defined 100% correctly. I've turned on the MySQL debugging, and it works fine (connect successful if everything is correct and mysql server is up, and fail to connect if something is wrong or mysql server is down). Is the above code correct to check the mysql connection success or fail?
Use strickenkid's, I think it is more stable, plus it tells you if you connected or not without even needing to print.
Reply
#3

Quote:
Originally Posted by G-sTyLeZzZ
mysql_connect( const host[], const user[], const database[], const password[] )
* Returns a connection handle you can use for multiple connections
So no, it returns the connection handle.

To check for a connection failure, use mysql_ping.

pawn Код:
public OnGameModeInit()
{
    mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
    if(mysql_ping() == -1) print("ERROR: Failed to connect database!");
    return 1;
}
Reply
#4

Thanks guys.
Reply
#5

Quote:
Originally Posted by The Toni
Посмотреть сообщение
Use strickenkid's, I think it is more stable, plus it tells you if you connected or not without even needing to print.
More stable? top most populars servers run gstyle's plugin.. what big server uses strickenkid's plugin?
Reply
#6

Quote:
Originally Posted by JernejL
Посмотреть сообщение
More stable? top most populars servers run gstyle's plugin.. what big server uses strickenkid's plugin?
sacnr #8

gstylez plugin was released very longer before strivcken kids you think a nice big server will have time to switch? good luck changing so many lines.
Reply
#7

Quote:
Originally Posted by Kar
Посмотреть сообщение
sacnr #8
ANY others? also, your argument is invalid, because the turtle disagrees!
Reply
#8

Quote:
Originally Posted by Kar
Посмотреть сообщение
sacnr #8

gstylez plugin was released very longer before strivcken kids you think a nice big server will have time to switch? good luck changing so many lines.
Changing many lines? Cntrl+H and it's done in less then 2 minutes.
Reply
#9

w/e i hate mysql anyways djson foreverD:
Reply
#10

Quote:
Originally Posted by Kar
Посмотреть сообщение
sacnr #8

gstylez plugin was released very longer before strivcken kids you think a nice big server will have time to switch? good luck changing so many lines.
SACNR has always used Adrenaline's MySQL plugin.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)