MySQL connection always failed!
#1

Hello guys, I'm learning about MySQL and I always get my connection failed.
PHP код:
#define MYSQL_HOST                                    "localhost"
#define MYSQL_USER                                    "root"
#define MYSQL_DATABASE                                "dbbase"
#define MYSQL_PASSWORD                                "123456"
ConnectMySQL(){ 
    
MHandle mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_DATABASEMYSQL_PASSWORD);
    if(
mysql_errno() != 0){
        print(
"[MYSQL] The connection was failed.");
        
printf("[MYSQL] Host : %s | User : %s | Database : %s | Password : %s"MYSQL_HOSTMYSQL_USERMYSQL_DATABASEMYSQL_PASSWORD);
    }else {
        print(
"[MYSQL] The connection was succesful.");
        
//SendRconCommand("exit");
    
}



I am using MySQL 5.5, MySQL Plugin R41-2, the lastest version.
Reply
#2

Correct parameters for mysql_connect in R40+ are
Код:
mysql_connect(const host[], const user[], const password[], const database[], MySQLOpt:option_id = MySQLOpt:0)
just switch between MYSQL_DATABASE and MYSQL_PASSWORD in your code
Код:
mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
https://sampwiki.blast.hk/wiki/MySQL/R40#mysql_connect
Reply
#3

It worked, thank you very much. REP+!
Reply
#4

edit: .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)