02.02.2014, 12:19
I'm using R34 of your plugin and I have a question.
Why does "mysql_connect" return 1, even when MySQL isn't running?
When I shutdown MySQL, or even change the name of the database (change the define to "ppctruck" for example, mysql_connect still returns "1".
When I add this code to check if the database really exists, it works fine even though mysql_connect still returns 1.
Why does "mysql_connect" return 1, even when MySQL isn't running?
pawn Код:
#define mysql_host "127.0.0.1"
#define mysql_user "PowerPC603"
#define mysql_password "MyPass"
#define mysql_database "ppctrucking"
public OnFilterScriptInit()
{
// Connect to the MySQL database and store the connection-handle
mysql_debug(1);
SQL_db = mysql_connect(mysql_host, mysql_user, mysql_database, mysql_password);
if (SQL_db)
printf("MySQL connection successful");
else
printf("MySQL failed to connect");
When I add this code to check if the database really exists, it works fine even though mysql_connect still returns 1.
pawn Код:
format(Query, sizeof(Query), "SHOW DATABASES LIKE '%s'", mysql_database);
mysql_query(SQL_db, Query);
mysql_store_result(SQL_db);
if (mysql_num_rows(SQL_db) == 1)
printf("Connecting to MySQL was successful, database \"%s\" exists", mysql_database);
else
{
printf("ERROR: Connecting to MySQL failed, database \"%s\" doesn't exist", mysql_database);
printf("Shutting down server...");
mysql_free_result(SQL_db);
mysql_close(SQL_db);
SetTimer("ShutdownServer", 5000, false);
return 1;
}

