SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Thread Tools Display Modes
Old 04/07/2018, 12:09 AM   #1
Huge Clucker
Join Date: May 2016
Location: Poland
Posts: 494
Reputation: 5
Default MySQL Connect

How to connect MySQL StrickenKid?
new MySQL:connection;

              connection = mysql_init(LOG_ONLY_ERRORS, 1); 
              mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DATA, connection, 1);

	if() // What to add?
              // Connect MySQL
              // No connect MySQL
	return 1;
KamilPolska is offline   Reply With Quote
Old 04/07/2018, 12:17 AM   #2
Join Date: Mar 2018
Posts: 177
Reputation: 14
Default Re: MySQL Connect

PHP Code:
// :: MySQL Database
#define MYSQL_HOST                 "localhost"
#define MYSQL_USER                 "root"
#define MYSQL_PASS                 ""
#define MYSQL_DATABASE             "server"

new MySQLDatabase;

// OnGameModeInit
new MySQLOptoption_id mysql_init_options();
mysql_set_option(option_idAUTO_RECONNECTtrue); // We will set that option to automatically reconnect on timeouts.
Database == MYSQL_INVALID_HANDLE || mysql_errno(Database) != 0// Checking if the database connection is invalid to shutdown.
"Connection to MySQL database has failed. Shutting down the server.");
printf("[DEBUG] Host: %s, User: %s, Password: %s, Database: %s"MYSQL_HOSTMYSQL_USERMYSQL_PASSMYSQL_DATABASE);

kovac is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Failed to connect. Can't connect to MySQL server on 'localhost' (10061). Gogorakis Server Support 4 14/08/2014 03:14 PM
CMySQLHandler::Connect() - Can't connect to MySQL server on (10061) (Error ID: 2003) Cesar203 Scripting Help 0 02/08/2014 06:20 PM
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 08:26 AM
Can't connect to local MySQL server through socket '/tmp/mysql.sock' Ivan_Pantovic Help Archive 4 03/08/2011 01:50 PM

All times are GMT. The time now is 11:31 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.