nwnxee / unified

Binaries available under the Releases tab on Github
https://nwnxee.github.io/unified
GNU General Public License v3.0
131 stars 92 forks source link

Something strange with SQL plugin #58

Closed BhaalM closed 6 years ago

BhaalM commented 6 years ago

When entering the init area of my module different scripts checks at "the same time" the same variable on the database. I know I should reconsider the way I'm doing this but anyway, what is strange is that although the query is always the same, the last one gives a "Syntax error" :/

Maybe its my fault, please tell me if you need more info.

[19:24:24] NWNX_SQL: Successful SQL query. Query ID: '109', Query: 'SELECT val FROM misc WHERE player='bhaal' AND tag='Prueba' AND name='VERSION_PJ'', Results Count: '1'.
I [19:24:24] NWNX_SQL: Successful SQL query. Query ID: '110', Query: 'SELECT val FROM misc WHERE player='bhaal' AND tag='Prueba' AND name='ROL_BONUS'', Results Count: '0'.
I [19:24:24] NWNX_SQL: Successful SQL query. Query ID: '111', Query: 'SELECT val FROM misc WHERE player='bhaal' AND tag='Prueba' AND name='VERSION_PJ'', Results Count: '1'.
I [19:24:24] NWNX_SQL: Successful SQL query. Query ID: '112', Query: 'SELECT val FROM misc WHERE player='bhaal' AND tag='Prueba' AND name='VERSION_PJ'', Results Count: '1'.
W [19:24:24] NWNX_SQL: Failed to prepare statement: 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 'player='bhaal' AND tag='Prueba' AND name='VERSION_PJ'' at line 1
mtijanic commented 6 years ago

Strange indeed. I'm not seeing anything in the code that would manifest like this. Could you please set the log level to debug (NWNX_SQL_LOG_LEVEL=7) and post the output? Note that this will print the DB password when starting the module - no need to post that as well :)

BhaalM commented 6 years ago

The log file is huge, so I'm only going to show the beginning and the log near the warning. I hope this will be enough.

Thank you!

I [13:06:59] NWNX_Core: Server is running version 8162.
I [13:06:59] NWNX_Core: Loading plugins from: .
I [13:06:59] NWNX_Core: Loaded plugin 0 (Chat) v1 by Liareth.
I [13:06:59] NWNX_Core: Loaded plugin 1 (Creature) v1 by various / sherincall.
I [13:06:59] NWNX_SQL: Connecting to type MYSQL
D [13:06:59] NWNX_SQL: DB set to silvermarch
I [13:06:59] NWNX_SQL: Connection info:  host=localhost username=nwn
D [13:06:59] NWNX_SQL:                :  password=xxxx
I [13:06:59] NWNX_Core: Loaded plugin 2 (SQL) v1 by Liareth.
D [13:07:26] NWNX_SQL: Preparing query SELECT val FROM sys WHERE player='~' AND tag='' AND name='MODULE_CALENDAR_DAY'

D [13:07:26] NWNX_SQL: Detected 0 parameters.
I [13:07:26] NWNX_SQL: Successful SQL query. Query ID: '1', Query: 'SELECT val FROM sys WHERE player='~' AND tag='' AND name='MODULE_CALENDAR_DAY'', Results Count: '1'.
D [13:07:26] NWNX_SQL: Preparing query SELECT val FROM sys WHERE player='~' AND tag='' AND name='MODULE_CALENDAR_MONTH'

.......

D [13:08:12] NWNX_SQL: Detected 0 parameters.
I [13:08:12] NWNX_SQL: Successful SQL query. Query ID: '111', Query: 'SELECT val FROM misc WHERE player='bhaal' AND tag='Prueba' AND name='VERSION_PJ'', Results Count: '1'.
D [13:08:12] NWNX_SQL: Preparing query SELECT val FROM misc WHERE player='bhaal' AND tag='Prueba' AND name='VERSION_PJ'

D [13:08:12] NWNX_SQL: Detected 0 parameters.
I [13:08:12] NWNX_SQL: Successful SQL query. Query ID: '112', Query: 'SELECT val FROM misc WHERE player='bhaal' AND tag='Prueba' AND name='VERSION_PJ'', Results Count: '1'.
D [13:08:12] NWNX_SQL: Preparing query UPDATE misc SET val='10',expire=0,last=now() player='bhaal' AND tag='Prueba' AND name='VERSION_PJ'

W [13:08:12] NWNX_SQL: Failed to prepare statement: 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 'player='bhaal' AND tag='Prueba' AND name='VERSION_PJ'' at line 1
D [13:08:13] NWNX_SQL: Preparing query SELECT val FROM misc WHERE player='bhaal' AND tag='Prueba' AND name='CC_ALLOWDD'

D [13:08:13] NWNX_SQL: Detected 0 parameters.
I [13:08:13] NWNX_SQL: Successful SQL query. Query ID: '113', Query: 'SELECT val FROM misc WHERE player='bhaal' AND tag='Prueba' AND name='CC_ALLOWDD'', Results Count: '0'.
D [13:08:13] NWNX_SQL: Preparing query SELECT val FROM misc WHERE player='bhaal' AND tag='Prueba' AND name='CC_ALLOWHARPER'

....
mtijanic commented 6 years ago

D [13:08:12] NWNX_SQL: Preparing query UPDATE misc SET val='10',expire=0,last=now() player='bhaal' AND tag='Prueba' AND name='VERSION_PJ'

You're missing a comma before player='bhaal'.

BhaalM commented 6 years ago

Ups... I've checked the syntax several times and didn't see that missing comma. I'm very sorry to make you loose your time :(

BhaalM commented 6 years ago

And it's not only a comma, its the full "WHERE ..." I feel quite stupid now.

Thank you!

mtijanic commented 6 years ago

No worries, glad it was resolved. Hopefully it helps someone else hitting similar issues..