View previous topic :: View next topic |
Author |
Message |
dacarlo
Joined: 22 Jul 2010 Posts: 6
|
Posted: Sun Jul 25, 2010 20:58 Post subject: Syntax muddled: Sql calls adding junk dots to queries |
|
|
I'm getting an odd database syntax error. The database log from nwnx2 looks like this.
Code: |
o Got request: SELECT * FROM guild_data WHERE id=1¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................
! SQL Error: 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 '¬...............................................................................' at line 1
|
It looks as though the code is adding a bunch of extra dots and ¬
The code that's generating it is this:
Code: |
void LoadGuildData() {
int iLocal;
int iGuards;
int iGuild = GetGuildID(OBJECT_SELF);
// Load the guild tables onto the masters
string sSQL = "SELECT * FROM guild_data WHERE id=" + IntToString(iGuild);
<snip>
|
Further up the code this:
int GetGuildID(object oNPC);
Grabs the int to string value.
Also seeing this
Code: |
o Got request: UPDATE guild_data SET power=0 WHERE id = 6
o Got request: SELECT id FROM players WHERE player = 'scrom'
o Got request: SELECT * FROM ban_keys WHERE cdkey = 'XXXXXXXX' or ip_addr = '192.168.1.72'¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................¬...............................................................................................................................
! SQL Error: 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 '¬...............................................................................' at line 1
o Got request: SELECT banned FROM ban_keys WHERE cdkey = 'XXXXXXXX' or ip_addr = '192.168.1.72'
|
For this code
Code: |
int IsBanned(object oPC) {
string sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oPC));
string sName = SQLEncodeSpecialChars(GetName(oPC));
string sKey = GetPCPublicCDKey(oPC);
string sIP = GetPCIPAddress(oPC);
string sSQL = "SELECT * FROM ban_keys WHERE cdkey = '" + sKey + "' or ip_addr = '" + sIP + "'";
|
But I can't quite fathom why. Any ideas? |
|
Back to top |
|
|
dacarlo
Joined: 22 Jul 2010 Posts: 6
|
Posted: Sun Jul 25, 2010 21:02 Post subject: |
|
|
MySQL 4.1 btw |
|
Back to top |
|
|
Fireboar
Joined: 17 Feb 2008 Posts: 323
|
Posted: Sun Jul 25, 2010 22:54 Post subject: |
|
|
All you've done in the code snippet given is assign a few variables within the scope of the function. That does nothing, so is not helpful in working out what your problem may be. Also, which database plugin are you using? (Name, version.) And which #include file? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sun Jul 25, 2010 23:25 Post subject: query assignment? |
|
|
Your not using += or anything similar when assigning the query to a string variable are you?
It almost looks like the string buffer is being added in as the query itself.
The string buffer is a 128 or 256 or higher, length string variable on the module itself, which stores querys and results.
If your function is mistakenly appending that buffer onto the end of your query, that would explain part of whats happening. |
|
Back to top |
|
|
dacarlo
Joined: 22 Jul 2010 Posts: 6
|
Posted: Sun Jul 25, 2010 23:27 Post subject: |
|
|
We're using the latest nwnx_odbc.dll from the download page and aps_include.
I've also had to run a conversion from fast french... |
|
Back to top |
|
|
|