MySQL Error (In the MySQL log)
#1

In My MySQL Log:
Код:
[Mon Feb 28 22:32:45 2011] -------------------------
[Mon Feb 28 22:32:45 2011]      Logging Started
[Mon Feb 28 22:32:45 2011] -------------------------
[Mon Feb 28 22:32:46 2011] Connected (0) to root @ localhost via TCP/IP.
[Mon Feb 28 22:32:46 2011] MySQL Server Version 5.5.8.
[Mon Feb 28 22:33:42 2011] 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 '' WHERE Username='я'' at line 1.
Look at the Bolded text, How to fix that?
Reply
#2

post your query line and/or format line
Reply
#3

You get/format the players username into the query incorrectly, which you could see if you looked at the error provided by the log file
Reply
#4

Format Line?
pawn Код:
format(queue, sizeof(queue), "SELECT * FROM `PlayerBans` WHERE IP='%s'",PlayerIP(playerid));
PS: Im new at MySQL and i looked at a tutorial =/
Reply
#5

Quote:
Originally Posted by Unknown123
Посмотреть сообщение
Format Line?
pawn Код:
format(queue, sizeof(queue), "SELECT * FROM `PlayerBans` WHERE IP='%s'",PlayerIP(playerid));
PS: Im new at MySQL and i looked at a tutorial =/
Do you see "Username" anywhere there?
Reply
#6

Quote:
Originally Posted by WackoX
Посмотреть сообщение
Do you see "Username" anywhere there?
No?!

Here i do:
pawn Код:
format(string, sizeof(string), "SELECT * FROM `PlayerBans` WHERE Username='%s'", PlayerName(playerid));
format(queue, sizeof(queue), "SELECT * FROM `Players` WHERE Username='%s'", PlayerName(playerid));
format(queue, sizeof(queue), "INSERT INTO `Players` (Username, Password, IP, Money, BankMoney) VALUES ('%s','%s','%s','7500','5000')",PlayerName(playerid), WPhash, PlayerIP(playerid));
format(queue, sizeof(queue), "SELECT * FROM `Players` WHERE Username='%s' AND Password='%s'",PlayerName(playerid),WPhash);
Reply
#7

Show us your PlayerName(playerid) code.
Reply
#8

Sorry for double post and bump i pressed wrong button, i meant to "Edit" last post...

Код:
[Mon Feb 28 23:53:34 2011] 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 '' WHERE Username='я'' at line 1.
That Error came from this line:
pawn Код:
stock SavePlayerAccount(playerid)
{
    new queue[184];
    format(queue, sizeof(queue), "UPDATE `Players` SET AdminLevel=%d, Score=%d, Money=%d, BankMoney=%d, Kills=%d, Deaths=%d' WHERE Username='%s'",PlayerData[playerid][AdminLevel], GetPlayerScore(playerid), GetPlayerMoney(playerid), PlayerData[playerid][BankMoney], PlayerData[playerid][Kills], PlayerData[playerid][Deaths]); //That Line!
    mysql_query(queue);
    return 1;
}
|
| And
|
Код:
sscanf warning: Format specifier does not match parameter count.
That Error came from this:
pawn Код:
if(mysql_num_rows())
                {
                    new row[265];
                    mysql_fetch_row(row, "|");
                    new name[MAX_PLAYER_NAME], IP[16], score, cash;
                    sscanf(row, "p<|>s[24]s[145]s[16]dddddds[28]s[11]", name, escape, IP, PlayerData[playerid][AdminLevel], score, cash, PlayerData[playerid][BankMoney], PlayerData[playerid][Kills], PlayerData[playerid][Deaths]); //That Line!
                    SetPlayerScore(playerid, score);
                    GivePlayerMoney(playerid, cash);
                    PlayerData[playerid][LoggedIn] = 1;
                }
Reply
#9

Username='%s'
You didn't gave any parameter to that in your format.
Reply
#10

Quote:
Originally Posted by WackoX
Посмотреть сообщение
Username='%s'
You didn't gave any parameter to that in your format.
You mean like this?
pawn Код:
format(queue, sizeof(queue), "UPDATE `Players` SET AdminLevel=%d, Score=%d, Money=%d, BankMoney=%d, Kills=%d, Deaths=%d' WHERE Username='%s'",PlayerData[playerid][AdminLevel], GetPlayerScore(playerid), GetPlayerMoney(playerid), PlayerData[playerid][BankMoney], PlayerData[playerid][Kills], PlayerData[playerid][Deaths], PlayerName(playerid));
if so, I get this Error:
Код:
[Tue Mar 01 00:10:44 2011] 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 '' WHERE Username='Unknown123'' at line 1.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)