server not connecting to mysql server
#1

Hi I'm having issues connecting to my mysql server im using wampp it worked fine before i've added more code to the script I'm not really sure what the issue is it doesnt give me any errors or anything it just doesnt send me the log saying if it connected or not to the server im using the lastest mysql plugin r41-4 im also using phoenix's easy-mysql include.
Before:
Quote:

----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, ©2005-2015 SA-MP Team

[19:10:47] filterscripts = "" (string)
[19:10:47]
[19:10:47] Server Plugins
[19:10:47] --------------
[19:10:47] Loading plugin: mysql.dll
[19:10:47] >> plugin.mysql: R41-4 successfully loaded.
[19:10:47] Loaded.
[19:10:47] Loading plugin: nativechecker.dll
[19:10:47] Loaded.
[19:10:47] Loading plugin: streamer.dll
[19:10:47]

*** Streamer Plugin v2.9.2 by Incognito loaded ***

[19:10:47] Loaded.
[19:10:47] Loading plugin: Whirlpool.dll
[19:10:47]
[19:10:47] ==================
[19:10:47]
[19:10:47] Whirlpool loaded
[19:10:47]
[19:10:47] ==================
[19:10:47]
[19:10:47] Loaded.
[19:10:47] Loaded 4 plugins.

[19:10:47]
[19:10:47] Filterscripts
[19:10:47] ---------------
[19:10:47] Loaded 0 filterscripts.

[19:10:48] AMX (23667336) loaded
[19:10:48] [MYSQL] - NOTICE: Successfully connected to database!
[19:10:48]
----------------------------------
[19:10:48] Test server
[19:10:48] ----------------------------------

[19:10:48] Number of vehicle models: 0

After:
Quote:

Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, ©2005-2015 SA-MP Team

[15:52:11] filterscripts = "" (string)
[15:52:11]
[15:52:11] Server Plugins
[15:52:11] --------------
[15:52:11] Loading plugin: mysql.dll
[15:52:11] >> plugin.mysql: R41-4 successfully loaded.
[15:52:11] Loaded.
[15:52:11] Loading plugin: sscanf.dll
[15:52:11]

[15:52:11] ===============================

[15:52:11] sscanf plugin loaded.

[15:52:11] Version: 2.8.2

[15:52:11] © 2012 Alex "******" Cole

[15:52:11] ===============================

[15:52:11] Loaded.
[15:52:11] Loading plugin: streamer.dll
[15:52:11]

*** Streamer Plugin v2.9.2 by Incognito loaded ***

[15:52:11] Loaded.
[15:52:11] Loading plugin: Whirlpool.dll
[15:52:11]
[15:52:11] ==================
[15:52:11]
[15:52:11] Whirlpool loaded
[15:52:11]
[15:52:11] ==================
[15:52:11]
[15:52:11] Loaded.
[15:52:11] Loading plugin: nativechecker.dll
[15:52:11] Loaded.
[15:52:11] Loaded 5 plugins.

[15:52:11]
[15:52:11] Filterscripts
[15:52:11] ---------------
[15:52:11] Loaded 0 filterscripts.

[15:52:11] AMX (19866176) loaded
[15:52:11]
----------------------------------
[15:52:11] Test server
[15:52:11] ----------------------------------

[15:52:11] Number of vehicle models: 0

Any help would be appreciated.Also im 100% sure that all the database connection info is corret.
Reply
#2

The first step would be to add a print message to your script that will execute if the connection is not successful.

The code I use is similar to below:
Код:
ConnectSQLDatabase()
{
	new MySQLOpt:options_id = mysql_init_options();
	mysql_set_option(options_id, AUTO_RECONNECT, false);

	SQL_HANDLE = mysql_connect(SQL_HOSTNAME, SQL_USERNAME, SQL_PASSWORD, SQL_DATABASE, options_id);
	if(mysql_errno(SQL_HANDLE) != 0 || SQL_HANDLE == MYSQL_INVALID_HANDLE)
	{
	    print("\n----------------------------------------------------");
		print("[ERROR] Cannot establish connection to MySQL database!");
		printf("[MYSQL] ERROR CODE: %d", mysql_errno(SQL_HANDLE));
		print("----------------------------------------------------");
	}
	else
	{
	    print("[MYSQL] Connection to MySQL database established successfully!");
	}
	return 1;
}
As you stated in your OP you should definitely confirm the connection details as being correct.
Reply
#3

It does have one check the first log.
Reply
#4

Quote:
Originally Posted by Hypex
Посмотреть сообщение
It does have one check the first log.
Yes but given you have not posted your code, I can only assume that based on the logs you provided that you only print a message if the connection is successful, what happens if it's not successful? Are you printing a message then also?

Have a look through your MySQL log file as this should be giving you some form of error as to why a connection isn't being established.
Reply
#5

yes it warns me if it fails also but from the looks of it it doesnt even try to connect to it
I get this warning in log-core:received Windows console close event; shutting log-core down
I thought it would be my .net framework so I just downloaded 4.7 and rebooted but still doesnt try to connect to it.
It's like its not even loading the easy-mysql include.
Reply
#6

Can you please post here the code that connects the database, and where it prints the success/fail messages.

You mentioned in your OP that this only started happening when you added some new code, what was the new code for? Did it change anything with your MySQL connection code?
Reply
#7

The code I added is non mysql related the easy-mysql include prints out the success/fail messages
Код:
#define SQL_Warning(%0)      				(printf("[MYSQL] - WARNING: " %0))
#define SQL_Error(%0)        				(printf("[MYSQL] - ERROR: " %0))
#define SQL_Notice(%0)						(printf("[MYSQL] - NOTICE: " %0))
Код:
#define mysql_host	"localhost"
#define mysql_user	"test1"
#define mysql_db    "release"
#define mysql_pass  "test123"
#define mysql_debugging_enabled    (true)
#define SQL_PLAYERS_TABLE	"Users"
ongminit
Код:
SQL::Connect(mysql_host, mysql_user, mysql_pass, mysql_db);
Reply
#8

Is there any other code under OnGameModeInit that could be preventing the connect function from being called?
Reply
#9

Unfortunetly no I have no idea why it's doing this as it worked fine a couple of days ago...
Reply
#10

Quote:
Originally Posted by Hypex
Посмотреть сообщение
Unfortunetly no I have no idea why it's doing this as it worked fine a couple of days ago...
Obviously something you have done in the past couple of days is causing this to happen.

Could you try placing the connect code somewhere else? Try placing it as the very first function to execute under OnGameModeInit:
Код:
OnGameModeInit()
{
	SQL::Connect(mysql_host, mysql_user, mysql_pass, mysql_db);
        // Other code below
}
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)