SA-MP Forums Archive
What's the problem? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What's the problem? (/showthread.php?tid=665590)



What's the problem? - Wavybone - 10.04.2019

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?


Re: What's the problem? - Crayder - 10.04.2019

Show us the definitions of SQL_HOST, SQL_USER, SQL_PASSWORD, and SQL_DATABASE.


Re: What's the problem? - Wavybone - 10.04.2019

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;



Re: What's the problem? - iorp - 10.04.2019

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://sampwiki.blast.hk/wiki/MySQL_Tutorial