mysql connection already exists
#1

I have recently opened a second server on the same host with the same "mysql_host" and "mysql_user" name.
Ever since I have the second server it says that the mysql_connection already exists in the mysql_log.txt.
Both server has both different scripts, just with the same mysql_host and mysql_user name.
mysql_database and mysql_password differs from each other though.

Both scripts are connecting to the database via OnGameModeInIt using 'variable = mysql_connect();'.

Question is; how do I prevent the 'connection already exists' warning I get.
Reply
#2

Make sure you don't attempt to connect twice from the same script, and that the details are correct.

Can we have a glance at the code where you connect and the entire mysql log when this happens? (remember to comment out any sensitive info..)
Reply
#3

Yep, I am not connecting twice from the same script, once each script.

Script 1:

PHP код:
new mysql;
#define MYSQL_H "localhost"
#define MYSQL_U "anol_4voetba"
#define MYSQL_D "zanol_4voetba2"
#define MYSQL_P "noob" 
PHP код:
public OnGameModeInit()
{
    
mysql_log(LOG_ALL);
    
mysql mysql_connect(MYSQL_HMYSQL_UMYSQL_DMYSQL_P);
    return 
1;

Script 2
PHP код:
new mysql;
#define MYSQL_HOST "localhost"
#define MYSQL_USER "anol_4voetba"
#define MYSQL_DATABASE "zanol_4voetba0"
#define MYSQL_PASSWORD "noob1" 
PHP код:
public OnGameModeInit()
{
    
mysql_log(LOG_ALL);
    
mysql mysql_connect(MYSQL_HOSTMYSQL_USERMYSQL_DATABASEMYSQL_PASSWORD);
    return 
1;

Literally all I got concering connecting to mysql in both scripts.
Reply
#4

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
If you have a filterscript which require to connect to your database, you will get the same warning.
You can use this in your OnGamemodeInit()
PHP код:
mysql_global_options(DUPLICATE_CONNECTIONStrue); 
Or on OnFilterScriptInit()
Reply
#5

Wauw, that simple thing fixed it, thanks.
Reply
#6

Use mysql_global_options() then mysql_ping() to make sure you're still being connected.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)