PDA

View Full Version : MySQL Issue


CoCo-Corello
31/07/2012, 12:11 AM
Hey guys, I'm wonderin' if you can help me with something. I've tried three separate queries, each... Have their own issues.


format(bigstring, sizeof(bigstring), "SELECT ID,Username,Registered,FirstLogin,LastLogin,Regist eredIP,CharacterSlots,Banned,LastCreated,Muted FROM "SQL_ACC" WHERE Username = '%s'",GetName(playerid));


This one, works like a charm.


format(bigstring, sizeof(bigstring), "SELECT ID,Username,Registered,FirstLogin,LastLogin,Regist eredIP,CharacterSlots,Banned,LastCreated,Muted,Gro up FROM "SQL_ACC" WHERE Username = '%s'",GetName(playerid));


^ Simply adding ",Group" to the query causes this:

Error ID: 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 'Group FROM Accounts WHERE `Username` = 'Corello'' at line 1


format(bigstring, sizeof(bigstring), "SELECT `ID`,`Username`,`Registered`,`FirstLogin`,`LastLog in`,`RegisteredIP`,`CharacterSlots`,`Banned`,`Last Created`,`Muted`,`Group` FROM "SQL_ACC" WHERE Username = '%s'",GetName(playerid));


^ Works, but it causes the script to freeze and doesn't load the next line of code.

Ideas?

Revo
31/07/2012, 12:17 AM
We're kinda lacking information, keep in mind MySQL is case sensitive (at some points) and "Group" would not be the same as "group" when selecting rows.

The reason `..` works is because `` supressess errors, I believe.

My information may not be 100% correct, anyone is feel to correct me if I am to be mistaken.

CoCo-Corello
31/07/2012, 12:20 AM
The table structure and case is correct, I've made sure of that already.

Pretty much, the first query works, it loads the characters and continues the script to do as it should.

The second obviously, has the MySQL issue which then stops the characters loading and then successfully loads later queries.

[01:23:02] CMySQLHandler::Query(SELECT ID,Username,Registered,FirstLogin,LastLogin,Regist eredIP,CharacterSlots,Banned,LastCreated,Muted,Gro up FROM Accounts WHERE `Username` = 'Corello') - An error has occured. (Error ID: 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 'Group FROM Accounts WHERE `Username` = 'Corello'' at line 1)
[01:23:02] >> mysql_store_result( Connection handle: 1 )
[01:23:02] CMySQLHandler::StoreResult() - No data to store.
[01:23:02] >> mysql_fetch_row_format( Connection handle: 1 )
[01:23:02] CMySQLHandler::FetchRow() - You cannot call this function now. (Reason: Empty Result)
[01:23:02] >> mysql_free_result( Connection handle: 1 )
[01:23:02] CMySQLHandler::FreeResult() - The result is already empty.

And the third query just freezes the script after login and doesn't process any queries after it.