MySQL Query Error.
#1

Hi everyone, I am quite new to MySQL, the script compiles fine, but in my MySQL log I get one error when trying to register.

17:33:31] [DEBUG] mysql_format - connection: 1, len: 400, format: "SELECT `Password`, `ID` FROM `users` WHERE `Username` = `%e` LIMIT 1"
[17:33:31] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Password`, `ID` FROM `users` WHERE `Username` = `Trevor`", callback: "OnAccountCheck", format: "i"
[17:33:31] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
[17:33:31] [ERROR] CMySQLQuery::Execute[OnAccountCheck] - (error #1054) Unknown column 'Trevor' in 'where clause'
[17:33:31] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - error will be triggered in OnQueryError
[17:33:31] [DEBUG] Calling callback "OnQueryError"..

I am also using MySQL R39-2.

My code, the spot where it gives the errors.
pawn Код:
public OnPlayerConnect(playerid)
{
    new query[400];
    GetPlayerName(playerid, Name[playerid], 24);
    GetPlayerIp(playerid, IP[playerid], 16);
    mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `users` WHERE `Username` = `%e` LIMIT 1", Name[playerid]);
    mysql_tquery(mysql, query, "OnAccountCheck","i", playerid);
    return 1;
}

//MySQL Account Check
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, mysql);
    if(rows)
    {
       cache_get_field_content(0, "PASS", pInfo[playerid][Password], mysql, 129);
       pInfo[playerid][ID] = cache_get_field_content_int(0, "ID");
       printf("%s", pInfo[playerid][Password]);
       ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login", "Welcome back, please introduce your password to log in.","Login","Quit");
    }
    else
    {
       ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Register", "You do not have a Account, please register one!","Register","Quit");
    }
    return 1;
}
Any suggestions are always appreciated!, Thanks guys
Reply
#2

Fixed.
Reply


Forum Jump:


Users browsing this thread: