SA-MP Forums Archive
MySQL Problems - 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 Problems (/showthread.php?tid=588988)



MySQL Problems - kiloman3 - 14.09.2015

For some reason I am getting this problem

Code:
CMySQLHandler::Query(яяяя) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'яяяя' at line 1)
Being brought about by this line

Code:
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s,'0')",GetPlayerName(playerid),EscapedText);
Any help would be great thanks.


Respuesta: MySQL Problems - Zume - 14.09.2015

the values from EscapedText?


Re: Respuesta: MySQL Problems - kiloman3 - 14.09.2015

Quote:
Originally Posted by _Zume
View Post
the values from EscapedText?
Thanks for the reply
Here are is EscapedText

All takes place under OnDialogResponse

Code:
ShowPlayerDialog(playerid,1336,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password for it! \n","Register!","");
Code:
mysql_real_escape_string(inputtext, EscapedText);



Re: MySQL Problems - nezo2001 - 14.09.2015

PHP Code:
printf("[MySql]   %s"Query); 
And show us this part from the server log.


Re: MySQL Problems - kiloman3 - 14.09.2015

Quote:
Originally Posted by nezo2001
View Post
PHP Code:
printf("[MySql]   %s"Query); 
And show us this part from the server log.
Thanks for the help

Here is what you requested

Code:
[21:54:21] [MySql]   ”SERT INTO `Users` (Username,Password,Money) VALUES ('',','0')



Re: MySQL Problems - kiloman3 - 15.09.2015

BUMP


Re: MySQL Problems - xVIP3Rx - 15.09.2015

I believe you are messing a " ' ", colored red in the line.
Code:
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s','0')",GetPlayerName(playerid),EscapedText);
Also looks like your query isn't formatted properly, as it's giving blank values instead of a password/name

If you would post the whole function or callback I believe I will be able to help.


Re: MySQL Problems - kiloman3 - 17.09.2015

Quote:
Originally Posted by xVIP3Rx
View Post
I believe you are messing a " ' ", colored red in the line.
Code:
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s','0')",GetPlayerName(playerid),EscapedText);
Also looks like your query isn't formatted properly, as it's giving blank values instead of a password/name

If you would post the whole function or callback I believe I will be able to help.
Thanks for the reply, seems I and others overlooked this little late night amatuer mistake.

Code:
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s', '%s', '0')",GetPlayerName(playerid),EscapedText);
Should be:

Code:
GetPlayerName(playerid, PlayerNameSQL, sizeof(PlayerNameSQL));
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s', '%s', '0')",PlayerNameSQL,EscapedText);
Works as desired now, thanks to all that gave me some tips.