logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Syntax muddled: Sql calls adding junk dots to queries

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related
View previous topic :: View next topic  
Author Message
dacarlo



Joined: 22 Jul 2010
Posts: 6

PostPosted: Sun Jul 25, 2010 20:58    Post subject: Syntax muddled: Sql calls adding junk dots to queries Reply with quote

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
View user's profile Send private message
dacarlo



Joined: 22 Jul 2010
Posts: 6

PostPosted: Sun Jul 25, 2010 21:02    Post subject: Reply with quote

MySQL 4.1 btw
Back to top
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Sun Jul 25, 2010 22:54    Post subject: Reply with quote

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
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Sun Jul 25, 2010 23:25    Post subject: query assignment? Reply with quote

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
View user's profile Send private message
dacarlo



Joined: 22 Jul 2010
Posts: 6

PostPosted: Sun Jul 25, 2010 23:27    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Database related All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group