SQL HELP - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SQL HELP (
/showthread.php?tid=623600)
SQL HELP -
Pearson - 02.12.2016
Hello guys.
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;
}
And Heres log
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
Can someone tell me whats wrong here?
Re: SQL HELP -
Dayrion - 02.12.2016
Maybe this should be :
PHP код:
mysql_format(MySQL, query, sizeof(query), "SELECT * FROM Users WHERE name = '%e'", GetName(playerid));
mysql_pquery(MySQL, query, "OnPlayerLoadInfo", "i", playerid);
Re: SQL HELP -
oMa37 - 02.12.2016
Код:
SELECT `ID`, `Password`, FROM users WHERE Username = '%e'
There is an extra comma after the `Password`.
Re: SQL HELP -
Pearson - 02.12.2016
Oooh thanks guys. +REP