Mysql Error:
#1

Код:
Error (0): Failed to exeute query. 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 ''15.374' at line 1.
What do that code mean?

code I assume you need to know:

pawn Код:
stock SavePlayerData(playerid)
{
    new query[128], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
    GetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
    format(query, sizeof(query), "UPDATE accounts SET Name = '%s', Password = '%s', Money = '%d', PlayerX = '%f', PlayerY = '%f', PlayerZ = '%f' WHERE Name = '%s'",
                                                                                PlayerInfo[playerid][pName],
                                                                                PlayerInfo[playerid][pPw],
                                                                                PlayerInfo[playerid][pMoney],
                                                                                PlayerInfo[playerid][pPos_x],
                                                                                PlayerInfo[playerid][pPos_y],
                                                                                PlayerInfo[playerid][pPos_z],
                                                                                pname
                                                                                );
    mysql_query(query);
}
Reply
#2

''15.374' You're not closing the quotation. One quotation from the error and the 2nd one is yours.

Also, enclose your identifiers with a back tick ( ` ). Here's an example:

Код:
"UPDATE accounts SET Name = '%s',
Should be:

Код:
"UPDATE `accounts` SET `Name` = '%s',
Reply
#3

not working though
Reply
#4

Try just using
pawn Код:
print(query);
I have a feeling that the query string is too small. You may want to increase that from 128.
Reply
#5

Код:
UPDATE accounts SET Name = 'LongUserName_asdasdsdfra', Password = 'AVerylongpasswordOrMD5?20381039812038120381029381029', Money = '100000', PlayerX = '10.00000', PlayerY = '10.00000', PlayerZ = '10.00000' WHERE Name = 'LongUserName_asdasdsdfra'
This is an example of your query.. the size with all informations is 244, 128 is too small


Edit: Pwned by [HiC]TheKiller .. too late XD
Reply
#6

Quote:
Originally Posted by gtakillerIV
Посмотреть сообщение
''15.374' You're not closing the quotation. One quotation from the error and the 2nd one is yours.

Also, enclose your identifiers with a back tick ( ` ). Here's an example:

Код:
"UPDATE accounts SET Name = '%s',
Should be:

Код:
"UPDATE `accounts` SET `Name` = '%s',
Backticks are optional. I prefer to use them but they are not required by any means.
Reply
#7

If you don't know how to use MySQL, then don't even try. Go read up on writing a proper MySQL query before you start coding a whole system.

You don't need apostrophe's around all non-string placeholders. Where you have '%d' it should be %d- the same goes for %f, %i, %x, etc. The only time you should surround a placeholder in an apostrophe is if it's a string (i.e. %s).
Reply
#8

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
If you don't know how to use MySQL, then don't even try. Go read up on writing a proper MySQL query before you start coding a whole system.

You don't need apostrophe's around all non-string placeholders. Where you have '%d' it should be %d- the same goes for %f, %i, %x, etc. The only time you should surround a placeholder in an apostrophe is if it's a string (i.e. %s).
Apostrophes around all placeholders is completely valid and makes code more organized, along with the wrapping of column names in `.
Reply
#9

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
Apostrophes around all placeholders is completely valid and makes code more organized, along with the wrapping of column names in `.
It's not, acually. Wrapping column and table names with a grave is fine, but using apostrophes for everything isn't a common practice and should be avoided unless you're dealing with strings.
Reply
#10

idk what's the problem goin' on here, but what I know that when I add new 3 columns, that error occurs in the debug.

error:
Код:
Error (0): Failed to exeute query. 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 ''15.4' at line 1.
Код:
	PlayerX	float(7,4)	
        PlayerY	float(7,4)		
        PlayerZ	float(7,4)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)