MYSQL syntax error
#1

Solved!
Solution:

php strings require a single quote ( ' ) around them, else you'll end up with a syntax error.
Per-example: '%s'


Quote:
Originally Posted by SQL error log
[00:18:10] CMySQLHandler::Query(INSERT INTO `playerdatabase` (`SQLID`,`Name`,`IP`,`OnlineTime`,`Admin`,`Helper` ,`Character1SQLID`,`Character2SQLID`,`Character3SQ LID`,`Pass`,`Banned`,`BanID`,`ProbationBy`,`Probat ionReason`,`ProbationUntil`,`Level`) VALUES (0,Wade456,127.0.0.1,178,0,0,0,0,0,18EC91CB4FF5D4A 5E8849583FB2BB1149A8355FC42377786DEF8660E3D7B801FC F1F3A4467DA2BE97A716902D409D70470232E4E4C7F7CC0C8E 3C790AE88138F,0,-1,'Never',Never,0,0)) - 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 '.0.1,178,0,0,0,0,0,18EC91CB4FF5D4A5E8849583FB2BB1 149A8355FC42377786DEF8660E3D7B8' at line 1)
Код:
new formatedmessage[500];
format(Globalquery,sizeof(Globalquery),"INSERT INTO `playerdatabase` (`SQLID`,`Name`,`IP`,`OnlineTime`,`Admin`,");
strcat(Globalquery,"`Helper`,`Character1SQLID`,`Character2SQLID`,`Character3SQLID`,`Pass`,`Banned`,");
strcat(Globalquery,"`BanID`,`ProbationBy`,`ProbationReason`,`ProbationUntil`,`Level`)");
format(formatedmessage,sizeof(formatedmessage)," VALUES (%d,%s,%s,%d,%d,%d,%d,%d,%d,%s,%d,%d,'%s',%s,%d,%d)",TotalRegistrations++,PlayerInfo[playerid][AccountName],
PlayerInfo[playerid][IP],OnlineTime, PlayerInfo[playerid][Admin],PlayerInfo[playerid][Helper],PlayerInfo[playerid][CharacterName1],PlayerInfo[playerid][CharacterName2],
PlayerInfo[playerid][CharacterName3],hashed,PlayerInfo[playerid][Banned],-1,"Never","Never",0,0);
strcat(Globalquery,formatedmessage);
mysql_query(Globalquery);

Information:

MySQL plugin version: BlueG's 5.0
Samp server version: 0.3x - 0.3.5.0

No compile errors - No runtime errors from the console.
In other areas of the script using the INSERT function, the script runs fine. I look for the issue to be something related to php in the formatting, which I'm unfamiliar with.
Reply


Messages In This Thread
MYSQL syntax error - by Enforcer501 - 07.05.2013, 23:49
Re: MYSQL syntax error - by Pooh7 - 08.05.2013, 00:06
Re: MYSQL syntax error - by Enforcer501 - 08.05.2013, 00:09

Forum Jump:


Users browsing this thread: 1 Guest(s)