SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 10/04/2019, 04:08 AM   #1
Wavybone
Little Clucker
 
Join Date: Jan 2019
Posts: 3
Reputation: 0
Default What's the problem?

Code:
public OnGameModeInit()
{
    if(mysql_connect(SQL_HOST, SQL_USER, SQL_PASSWORD, SQL_DATABASE, sqlConnection, 1))
    {
		printf("[DATABASE]: Connection failed to the database '%s'.", SQL_DATABASE);
	}
	else
	{
		printf ("[MYSQL]: Connection established to database '%s'.", SQL_DATABASE);
	}
	mysql_log(ERROR | WARNING);
    return true;
}
Of course I have my SQL info defined. sqlConnection is defined as
new MySQLqlConnection
4 errors on one line:
Code:
    if(mysql_connect(SQL_HOST, SQL_USER, SQL_PASSWORD, SQL_DATABASE, sqlConnection, 1))
invalid expression assumed zero
expression has no effect
The fucks going on?
Wavybone is offline   Reply With Quote
Old 10/04/2019, 04:29 AM   #2
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: What's the problem?

Show us the definitions of SQL_HOST, SQL_USER, SQL_PASSWORD, and SQL_DATABASE.
Crayder is offline   Reply With Quote
Old 10/04/2019, 04:34 AM   #3
Wavybone
Little Clucker
 
Join Date: Jan 2019
Posts: 3
Reputation: 0
Default Re: What's the problem?

Quote:
Originally Posted by Crayder View Post
Show us the definitions of SQL_HOST, SQL_USER, SQL_PASSWORD, and SQL_DATABASE.
Code:
#define SQL_HOST = "localhost"
#define SQL_USER = "root"
#define SQL_DATABASE = "Test1"
#define SQL_PASSWORD = ""

new MySQL:sqlConnection;
Wavybone is offline   Reply With Quote
Old 10/04/2019, 05:09 AM   #4
iorp
Big Clucker
 
iorp's Avatar
 
Join Date: Sep 2018
Location: I do not live
Posts: 65
Reputation: 1
Default Re: What's the problem?

Quote:
Originally Posted by Wavybone View Post
Code:
#define SQL_HOST = "localhost"
#define SQL_USER = "root"
#define SQL_DATABASE = "Test1"
#define SQL_PASSWORD = ""

new MySQL:sqlConnection;
wrong define usage, use this to fix your problem
Code:
#define SQL_HOST "localhost"
#define SQL_USER "root"
#define SQL_DATABASE "Test1"
#define SQL_PASSWORD ""
but you have used wrong parameters in your "mysql_connect"

use this
Code:
    sqlConnection = mysql_connect(SQL_HOST, SQL_USER, SQL_PASSWORD, SQL_DATABASE, MySQLOpt:1)
or check out this tutorial https://wiki.sa-mp.com/wiki/MySQL_Tutorial
__________________
Indian Ocean Roleplay

iorp is offline   Reply With Quote
Reply

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
Password Hash Problem & MYSQL Saving Problem Faqahat Scripting Help 3 18/04/2016 11:54 AM
[SOLVED] 3 problem's! (1 problem still unsolved, but stopped solving.) Mechscape Help Archive 9 24/12/2009 08:47 PM


All times are GMT. The time now is 06:23 AM.


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