SQL HELP
#1

Hello guys.
I have problem in sql.
Heres my code.
PHP код:
public OnPlayerConnect(playerid)
{
    
RemoveObjects(playerid);
    
TogglePlayerSpectating(playeridtrue);
    new 
szQuery[3000];
    
mysql_format(dbHandleszQuerysizeof szQuery"SELECT `ID`, `Password`,  FROM users WHERE Username = '%e'"Name(playerid));
    
mysql_tquery(dbHandleszQuery"OnAccountCheck""d"playerid);
    return 
1;

PHP код:
public OnAccountCheck(playerid)
{
       if(
cache_get_row_count(dbHandle) == 1)
    {
        new 
tmp[3000];
        
cache_get_field_content(0"Password"tmp); format(g_PlayerData[playerid][ePassword], 129"%s"tmp);
        
g_PlayerData[playerid][eId] = cache_get_field_content_int(0"ID");
        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Log In""Insert your password to login""Login""Quit");
    } else
    {
        
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Register""Insert a password to register.""Register""Quit");
    }
    return 
1;

And Heres log
PHP код:
15:48:04    mysql_connect    OK    host"127.0.0.1"user"root"database"xwarfare"password"****"port3306autoreconnecttruepool_size2
15
:48:04    CMySQLHandle::Create    OK    creating new connection..
15:48:04    CMySQLHandle::CMySQLHandle    OK    constructor called
15
:48:04    CMySQLHandle::Create    OK    connection created (id1)
15:48:04    CMySQLConnection::Connect    OK    establishing connection to database...
15:48:04    CMySQLConnection::Connect    OK    connection was successful
15
:48:04    CMySQLConnection::Connect    OK    auto-reconnect has been enabled
15
:48:04    mysql_errno    OK    connection1
15
:48:04    CMySQLConnection::Connect    OK    establishing connection to database...
15:48:04    CMySQLConnection::Connect    OK    establishing connection to database...
15:48:04    CMySQLConnection::Connect    OK    establishing connection to database...
15:48:04    CMySQLConnection::Connect    OK    connection was successful
15
:48:04    CMySQLConnection::Connect    OK    auto-reconnect has been enabled
15
:48:04    CMySQLConnection::Connect    OK    connection was successful
15
:48:04    CMySQLConnection::Connect    OK    auto-reconnect has been enabled
15
:48:04    CMySQLConnection::Connect    OK    connection was successful
15
:48:04    CMySQLConnection::Connect    OK    auto-reconnect has been enabled
15
:48:24    mysql_format    OK    connection1len128format"SELECT ID, Password, FROM users WHERE Username = '%e' LIMIT 1"
15:48:24    mysql_tquery    OK    connection1query"SELECT ID, Password, FROM users WHERE Username = 'MedzvelAa' LI"callback"OnAccountCheck"format"i"
15:48:24    CMySQLQuery::Execute[OnAccountCheck]    OK    starting query execution
15
:48:24    CMySQLQuery::Execute[OnAccountCheck]    ERROR    (error #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 'FROM users WHERE Username = 'MedzvelAa' LIMIT 1' at line 1
15:48:24    CMySQLQuery::Execute[OnAccountCheck]    OK    error will be triggered in OnQueryError 
Can someone tell me whats wrong here?
Reply
#2

Maybe this should be :
PHP код:
    mysql_format(MySQLquerysizeof(query), "SELECT * FROM Users WHERE name = '%e'"GetName(playerid));
    
mysql_pquery(MySQLquery"OnPlayerLoadInfo""i"playerid); 
Reply
#3

Код:
SELECT `ID`, `Password`,  FROM users WHERE Username = '%e'
There is an extra comma after the `Password`.
Reply
#4

Oooh thanks guys. +REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)