01.01.2018, 04:22
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:
As you stated in your OP you should definitely confirm the connection details as being correct.
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; }