Server doesn't seem to connect to the MySQL database -
Jimmy0wns - 13.02.2015
As the title says, when connecting to the database, it's outputting that the attempt failed.
MySQL Logs
Code:
[22:41:41] [ERROR] "mysql_errno" - invalid connection handle (id: 1)
Script to connect to database
pawn Code:
m_iHandle = mysql_connect(SQL_HOSTNAME, SQL_USERNAME, SQL_DATABASE, SQL_PASSWORD, 3306, true, 2);
switch (mysql_errno(m_iHandle))
{
case 0: printf("[SQL] Connection to \"%s\" failed! Please check the connection settings...\a", SQL_HOSTNAME);
default: printf("[SQL] Connection to \"%s\" passed!", SQL_HOSTNAME);
}
pawn Code:
#define SQL_HOSTNAME "removed"
#define SQL_USERNAME "removed_jimmy"
#define SQL_DATABASE "removed_newdb"
#define SQL_PASSWORD "removed"
Re: Server doesn't seem to connect to the MySQL database -
Maximus0 - 13.02.2015
Be sure you have attached your server IP on remote MySql. Also remember free hosting like 000webhost doesn't provided remote Mysql.
Re: Server doesn't seem to connect to the MySQL database -
Jimmy0wns - 13.02.2015
I have, it doesn't even work with a local database, nor I'm hosted at 000webhost, never heard of it anyways.
Quick explanation: Editing an old script, updating everything MySQL related and server doesn't want to connect anymore.
Re: Server doesn't seem to connect to the MySQL database -
Maximus0 - 13.02.2015
*) Which mysql version and plugin are you using?
*) Do you get any warnings while you compile?
*) How did you define m_iHandle?
Re: Server doesn't seem to connect to the MySQL database -
Jimmy0wns - 13.02.2015
Quote:
Originally Posted by Maximus0
*) Which mysql version and plugin are you using?
*) Do you get any warnings while you compile?
*) How did you define m_iHandle?
|
Latest version BlueG
None
new m_iHandle;
Re: Server doesn't seem to connect to the MySQL database -
Maximus0 - 13.02.2015
I have downloaded the latest version of mysql by BlueG and testing your script with some changes.
Try this!
Code:
new m_iHandle = mysql_connect(SQL_HOSTNAME, SQL_USERNAME, SQL_DATABASE, SQL_PASSWORD, 3306, true, 2);
if(mysql_errno() != 0)
printf("[SQL] Connection to \"%s\" failed! Please check the connection settings...\a", SQL_HOSTNAME);
printf("[SQL] Connection to \"%s\" passed!", SQL_HOSTNAME);
Re: Server doesn't seem to connect to the MySQL database -
Jimmy0wns - 13.02.2015
It seems to work now, it must be something with the mysql_errno though, because it's still logging this:
Code:
"mysql_errno" - invalid connection handle (id: 1)
Re: Server doesn't seem to connect to the MySQL database -
Maximus0 - 13.02.2015
But I didn't manage to see that kind of before with me. Also, I have checked my current log (Everything fine).
Re: Server doesn't seem to connect to the MySQL database -
Vince - 13.02.2015
The fact that you censored the hostname tells me that it is not localhost or 127.0.0.1, which it probably should be. For some obscure reason, loads of people get this wrong.
Re: Server doesn't seem to connect to the MySQL database -
Jimmy0wns - 13.02.2015
Quote:
Originally Posted by Vince
The fact that you censored the hostname tells me that it is not localhost or 127.0.0.1, which it probably should be. For some obscure reason, loads of people get this wrong.
|
It couldn't be local because it's hosted on another IP on the same dedicated server. (We use a dedicated server with virtual VPSs)