MY CODE
PHP Code:
bool:fm_db_connect(&Sql:sql) {
new Handle:g_SqlTuple
const LEN = 128
new host[LEN], user[LEN], pass[LEN], db[LEN], error_msg[LEN]
get_cvar_string(CVAR_HOST, host, LEN - 1)
get_cvar_string(CVAR_USER, user, LEN - 1)
get_cvar_string(CVAR_PASS, pass, LEN - 1)
get_cvar_string(CVAR_DB, db, LEN - 1)
g_SqlTuple = SQL_MakeDbTuple(host,user,pass,db)
new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,error_msg,511)
if(SqlConnection == Empty_Handle){
// stop the plugin with an error message
set_fail_state(error_msg)
log_amx("[%s] ERROR - Can't connect to SQL db: %s", PLUGINNAME, error_msg)
server_print("[%s] ERROR - Can't connect to SQL db: %s", PLUGINNAME, error_msg)
return false
else{
server_print("[%s] Successfully connected to SQL db.", PLUGINNAME)
return true
}
}
}