View previous topic :: View next topic |
Author |
Message |
Urlord
Joined: 17 Nov 2006 Posts: 122
|
Posted: Tue Dec 05, 2006 9:38 Post subject: Odd results when saving |
|
|
When doing the following:
Code: |
string sFullName = GetName(oPC);
SetPersistentString(oPC, "PC_Full_Name", sFullName);
|
I get the following value in the database: NWNX!SQL!GET_ESCAPE_STRING
The First Name of the PC is: Test
The Last Name of the PC is: Dwarf Female
Any clues?
I am using v1.06. _________________ Jim (aka, Urlord)
Visit the Persistent World of Nymri |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Tue Dec 05, 2006 10:19 Post subject: |
|
|
With SQLite ? There is a problem in that plugin that was introduced with the feature that keeps resultsets if a query returns no row. _________________ Papillon |
|
Back to top |
|
|
Urlord
Joined: 17 Nov 2006 Posts: 122
|
Posted: Tue Dec 05, 2006 15:01 Post subject: |
|
|
Papillon wrote: | With SQLite ? There is a problem in that plugin that was introduced with the feature that keeps resultsets if a query returns no row. |
Sorry - No, this is with MySQL 4.1. _________________ Jim (aka, Urlord)
Visit the Persistent World of Nymri |
|
Back to top |
|
|
Grumalg
Joined: 04 Nov 2005 Posts: 70
|
Posted: Tue Dec 05, 2006 15:28 Post subject: |
|
|
Just for giggles, did ya check the data just before ya try to write it? Perhaps the DB stuff is ok, but the input to it is bad. I find it hard to imagine how the DB stuff could make up a result such as that...
--- Grumalg --- |
|
Back to top |
|
|
Urlord
Joined: 17 Nov 2006 Posts: 122
|
Posted: Tue Dec 05, 2006 16:23 Post subject: |
|
|
Grumalg wrote: | Just for giggles, did ya check the data just before ya try to write it? Perhaps the DB stuff is ok, but the input to it is bad. I find it hard to imagine how the DB stuff could make up a result such as that...
--- Grumalg --- |
Yes I have checked the data - Just before the SQL call, I SendMessageToPC(oPC, sFullName) and it is right.
On a related note, I notice that the SetPersistentString function SQLEncodeSpecialChars all data before adding it to the DB - This is a good thing. However, the value is not Decoded before it is returned with the GetPersistentString function and I cannot locate the SQLDecodeSpceialChars function. Am I blind? _________________ Jim (aka, Urlord)
Visit the Persistent World of Nymri |
|
Back to top |
|
|
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Tue Dec 05, 2006 18:47 Post subject: |
|
|
You don't need SQLDecodeSpecialChars now because SQLEncodeSpecialChars war rewritten... |
|
Back to top |
|
|
Urlord
Joined: 17 Nov 2006 Posts: 122
|
Posted: Tue Dec 05, 2006 19:02 Post subject: |
|
|
caloup wrote: | You don't need SQLDecodeSpecialChars now because SQLEncodeSpecialChars war rewritten... |
So, if I do:
SetPersistentString(oPC, "FULL_NAME", "Ole' Jean Du'Marc")
GetPersistentString(oPC, "FULL_NAME")
It will be stored as: Ole~ Jean Du~Marc
And come out as: Ole' Jean Du'Marc
[EDIT]
I just tested it and the ' is no longer replaced with the ~. Very nice.
I still need to use SQLEncodeSpecialChars() when building my own SQL statements and submitting with SQLExecuteDirict, Right?
[/EDIT]
Cool - I must have missed the dicussion on that.
Thanks. _________________ Jim (aka, Urlord)
Visit the Persistent World of Nymri |
|
Back to top |
|
|
Papillon x-man
Joined: 28 Dec 2004 Posts: 1060 Location: Germany
|
Posted: Tue Dec 05, 2006 20:45 Post subject: |
|
|
Urlord wrote: |
I just tested it and the ' is no longer replaced with the ~. Very nice.
I still need to use SQLEncodeSpecialChars() when building my own SQL statements and submitting with SQLExecuteDirict, Right?
|
That is correct. SQLEncodeSpecialChars calls a function in the active DB plugin that escapes the ' character in a way the DB can handle. In MySQL, you will find these characters have a backslash in front of them: \'.
There was no real discussion on that... I just pointed it out in the changelog, really .
Hmm, does the problem still persist ? From your comment, it sounds like it works now ? _________________ Papillon |
|
Back to top |
|
|
wizard341
Joined: 19 Dec 2006 Posts: 15
|
Posted: Tue Dec 19, 2006 10:28 Post subject: |
|
|
Hey guys, I'm getting the same sort of issue here... I'm doing something like this :
Code: | string sUniqueID = CreateUniquePlayerID(oPC);
SetPersistentString(GetModule(),"Portal" + IntToString(iNumberOfPortals) + sUniqueID , GetTag(OBJECT_SELF)); |
Code: |
string CreateUniquePlayerID(object oPlayer)
{
return GetFirstName(oPlayer) + GetLastName(oPlayer) + GetPCPublicCDKey(oPlayer);
} |
This gives me that NWNX!SQL!GET_ESCAPE_STRING error that was popping up. The characters name wasn't anything special, it was Cylla Meadows. I fooled around with the CreateUniquePlayerID, and if it changed it to this...
Code: |
string CreateUniquePlayerID(object oPlayer)
{
return GetFirstName(oPlayer) /*+ GetLastName(oPlayer) + GetPCPublicCDKey(oPlayer)*/;
} |
it would work fine. So it seems that both the last name and the public CD key are generating some bad data. Any ideas? Thanks in advance! |
|
Back to top |
|
|
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Tue Dec 19, 2006 14:53 Post subject: |
|
|
You should try to put your Get function in a variable like :
string sUniqueID = GetFirstName(oPlayer)+GetLastName(oPlayer)+GetPCPublicCDKey(oPlayer);
SendMessage(oPlayer,"My variable is :"+sUniqueID);
string CreateUniquePlayerID(object oPlayer)
{
return sUniqueID;
}
and report us what you have obtain.... |
|
Back to top |
|
|
wizard341
Joined: 19 Dec 2006 Posts: 15
|
Posted: Wed Dec 20, 2006 4:52 Post subject: |
|
|
I ran the tests you suggested, with the following code
Code: |
string CreateUniquePlayerID(object oPlayer)
{
string sPlayerName = GetFirstName(oPlayer);
MSG("UniqueID : " + sPlayerName);
return sPlayerName;/*GetFirstName(oPlayer) /*+ GetLastName(oPlayer) + GetPCPublicCDKey(oPlayer)*/;
}
|
I get the following output UniqueID : Cylla
with the other code,
Code: |
string CreateUniquePlayerID(object oPlayer)
{
string sPlayerName = GetFirstName(oPlayer) + GetLastName(oPlayer) + GetPCPublicCDKey(oPlayer);
MSG("UniqueID : " + sPlayerName);
return sPlayerName;/*GetFirstName(oPlayer) /*+ GetLastName(oPlayer) + GetPCPublicCDKey(oPlayer)*/;
} |
I get the following output UniqueID : CyllaMeadowsMJAB6AGT
however this output causes that NWNX!SQL!GET_ESCAPE_STRING error. That error appears in the 'name' portion of the database, the 'val' seems fine. Also forgot to mention that I am running mySQL 5.0.
The following test was performed using a character named Cylla Meadows. |
|
Back to top |
|
|
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Wed Dec 20, 2006 8:28 Post subject: |
|
|
is it a part of your CDKEY ? : MJAB6AGT
You should'nt have the " ; " in :
You already have a " ; " before.
write this :
Quote: |
return sPlayerName;/*GetFirstName(oPlayer)+ GetLastName(oPlayer) + GetPCPublicCDKey(oPlayer);*/
|
Just a test :
Try do do this :
Quote: |
string sCDKey = GetPCPublicCDKey(oPlayer);
SendMessageToPC(oPlayer, sCDKey);
|
Don't show us the result just tell us if you get the real value for your CDKey...
If with that you have the real value, i think when you're trying to make your UniqueId the variable is cut...Is there a limit in the number of letter ?
For your function :
Quote: |
"Portal" + IntToString(iNumberOfPortals) + sUniqueID |
Replace that by this :
Quote: |
string sVariable = "Portal" + IntToString(iNumberOfPortals) + sUniqueID ;
|
... |
|
Back to top |
|
|
wizard341
Joined: 19 Dec 2006 Posts: 15
|
Posted: Wed Dec 20, 2006 9:45 Post subject: |
|
|
OK - I think I did what you wanted me to.
I changed the variable to this...
Code: |
string sPortalVar = "Portal" + IntToString(iNumberOfPortals) + CreateUniquePlayerID(oPC);
MSG("Portal VAr = " + sPortalVar);
SetPersistentString(GetModule(),sPortalVar , GetTag(OBJECT_SELF));
|
The Messsage prints out correctly, (it prints out Portal0CyllaMeadowsMJAB6AGT)
Code: |
string CreateUniquePlayerID(object oPlayer)
{
string sPlayerName = GetFirstName(oPlayer) + GetLastName(oPlayer) + GetPCPublicCDKey(oPlayer);
MSG("UniqueID : " + sPlayerName);
return sPlayerName;
} |
A side note - the PublicCD key doesn't equal your CD key, it appears to be some hashed value from it. Regardless, the PublicCD key I gave you isn't my actual key, but it's a basic representation of it (in terms of letters and numbers).
So after this testing I'm still confused. The output displays fine in game, but something is still causing an error to happen when I'm storing the value in mySQL.
Edit : did some more testing, and some weird results are occuring. I would wager to guess that the name is too long - or something? The following tests worked fine (that is to say I didn't get that error).
Code: |
string sPortalVar = "Po" + CreateUniquePlayerID(oPC) + IntToString(iNumberOfPortals);
|
Code: | string sPortalVar = "Po" + IntToString(iNumberOfPortals) + CreateUniquePlayerID(oPC); |
and finally
Code: | string sPortalVar = IntToString(iNumberOfPortals) + "Po" + CreateUniquePlayerID(oPC); |
As stated, these all work. If I add an 'r' to 'Po' however, that will break and I will get the error. What's really curious however about this situation, is it doesn't seem that length alone will give me this error, I have a variable being strored in my database called NumOfPortalsCyllaMeadowsMJAB6AGT which as you can see is a much longer name than that portal one I'm trying to store. So it seems to be a combination of length and numbers being stored. |
|
Back to top |
|
|
caloup
Joined: 29 Sep 2006 Posts: 59 Location: albi (france)
|
Posted: Wed Dec 20, 2006 16:39 Post subject: |
|
|
yes...
look to your pwdata table column value...how many varchar have you set ?
could you write your SQL query for create your table ? |
|
Back to top |
|
|
wizard341
Joined: 19 Dec 2006 Posts: 15
|
Posted: Wed Dec 20, 2006 20:06 Post subject: |
|
|
Initially the vchar length was set to 64, but I changed it to 128. I can look at the table and it does say that the length supports 128. |
|
Back to top |
|
|
|