MySQL - 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: MySQL (
/showthread.php?tid=515406)
MySQL -
Nathan_Taylor - 25.05.2014
Trying to change my script over to MySQL and I am getting the following error. I blocked out the password spot and part of the IP part.
pawn Код:
19. #define MYSQL_HOST 100.42.##.#:2082
20. #define MYSQL_USER nathant_naterp
21. #define MYSQL_DB nathant_naterp
22. #define MYSQL_PASS *******
23. #undef MAX_PLAYERS
24. #define MAX_PLAYERS 20
25.
26. ConnectMySQL()
27. {
28. if(mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS)){
29. print("[MySQL] Connection to the MySQL Database was successfully!");
30. } else {
31. print("[MySQL] Could not connect to the MySQL Database!");
32. }
33. }
Код:
C:\Users\Nate\Dropbox\SAMP 2\gamemodes\nateRP.pwn(28) : error 035: argument type mismatch (argument 1)
C:\Users\Nate\Dropbox\SAMP 2\gamemodes\nateRP.pwn(28) : error 029: invalid expression, assumed zero
C:\Users\Nate\Dropbox\SAMP 2\gamemodes\nateRP.pwn(28) : warning 215: expression has no effect
C:\Users\Nate\Dropbox\SAMP 2\gamemodes\nateRP.pwn(28) : error 001: expected token: ";", but found ":"
C:\Users\Nate\Dropbox\SAMP 2\gamemodes\nateRP.pwn(28) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Re: MySQL -
Konstantinos - 25.05.2014
They must be strings.
pawn Код:
#define MYSQL_HOST "100.42.x.x" // change x to the digits your IP has
#define MYSQL_USER "nathant_naterp"
#define MYSQL_DB "nathant_naterp"
#define MYSQL_PASS "*******"
and mysql_connect returns the connection handle not success or failure. If you use from the latest version, use mysql_errno.
Re: MySQL -
kamiliuxliuxliux - 25.05.2014
But shouldn't you use mysql_connect(); before checking for success of connection?
Re: MySQL -
Jacksta21 - 26.05.2014
If you want to print success or failure I use this.
pawn Код:
MySQL = mysql_connect(DB_HOST, DB_USER, DB_NAME, DB_PASS, 3306, true);
if(mysql_errno() != 0)
{
print("Unable to connect to the Database");
}
else
{
print("Connected to the database");
}
Works for me.