[MySQL] Error (0): Function: mysql_connect failed, mysql was not initialized on this handle.
public MySQLConnect(sqlhost[], sqluser[], sqlpass[], sqldb[])
{
print("MySQL: Connecting to MySQL...");
mysql_connect(sqlhost, sqluser, sqlpass, sqldb);
if(!mysql_ping())
{
print("MySQL: Connected to MySQL.");
return 1;
}
else
{
print("MySQL: Connection error, retrying...");
mysql_connect(sqlhost, sqluser, sqldb, sqlpass);
if(!mysql_ping())
{
print("MySQL: Connection established.");
mysql_free_result();
return 1;
}
else
{
print("MySQL: Can't connect with MySQL.");
SendRconCommand("exit");
return 0;
}
}
}
SA-MP Dedicated Server ---------------------- v0.3a R8, ©2005-2010 SA-MP Team [17:58:47] filterscripts = "" (string) [17:58:47] [17:58:47] Server Plugins [17:58:47] -------------- [17:58:47] Loading plugin: sscanf [17:58:47] [17:58:47] =============================== [17:58:47] sscanf plugin loaded. [17:58:47] © 2009 Alex "******" Cole [17:58:47] =============================== [17:58:47] Loaded. [17:58:47] Loading plugin: streamer [17:58:47] *** Streamer Plugin v2.3.3 by Incognito loaded *** [17:58:47] Loaded. [17:58:47] Loading plugin: mysql [17:58:47] SA:MP MySQL Plugin v2.0 Loaded. [17:58:48] Loaded. [17:58:48] Loaded 3 plugins. [17:58:48] [MySQL] Thread running. Threadsafe: Yes. [17:58:48] [17:58:48] Filter Scripts [17:58:48] --------------- [17:58:48] Loaded 0 filter scripts. [17:58:48] MySQL: Connecting to MySQL... [17:58:48] [MySQL] Error (0): Function: mysql_connect failed, mysql was not initialized on this handle.
public MySQLConnect(sqlhost[], sqluser[], sqlpass[], sqldb[])
{
print("MySQL: Connecting to MySQL...");
mysql_init();
mysql_connect(sqlhost, sqluser, sqlpass, sqldb);
if(!mysql_ping())
{
print("MySQL: Connected to MySQL.");
return 1;
}
else
{
print("MySQL: Connection error, retrying...");
mysql_connect(sqlhost, sqluser, sqldb, sqlpass);
if(!mysql_ping())
{
print("MySQL: Connection established.");
mysql_free_result();
return 1;
}
else
{
print("MySQL: Can't connect with MySQL.");
SendRconCommand("exit");
return 0;
}
}
}
//Under OnGameModeInIt is easy as this:
new MySQL:connection = mysql_init(1); //Log Everything
mysql_connect(sql_host, sql_user, sql_pass, sql_db, 1, connection);
It doesn't need to be as much as that, you can just do this, Stricken's automatically tells you if you are connected are not
pawn Код:
![]() |