02.12.2016, 14:19
Hello guys.
I have problem in sql.
Heres my code.
And Heres log
Can someone tell me whats wrong here?
I have problem in sql.
Heres my code.
PHP код:
public OnPlayerConnect(playerid)
{
RemoveObjects(playerid);
TogglePlayerSpectating(playerid, true);
new szQuery[3000];
mysql_format(dbHandle, szQuery, sizeof szQuery, "SELECT `ID`, `Password`, FROM users WHERE Username = '%e'", Name(playerid));
mysql_tquery(dbHandle, szQuery, "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(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Log In", "Insert your password to login", "Login", "Quit");
} else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Insert a password to register.", "Register", "Quit");
}
return 1;
}
PHP код:
15:48:04 mysql_connect OK host: "127.0.0.1", user: "root", database: "xwarfare", password: "****", port: 3306, autoreconnect: true, pool_size: 2
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 (id: 1)
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 connection: 1
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 connection: 1, len: 128, format: "SELECT ID, Password, FROM users WHERE Username = '%e' LIMIT 1"
15:48:24 mysql_tquery OK connection: 1, query: "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