AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   dbi buggy? (https://forums.alliedmods.net/showthread.php?t=11363)

kexz 03-17-2005 10:00

dbi buggy?
 
I'm running heavily modified version of admin_sql.sma... admins are not loaded into array but mysql-queried every time someone connects. Everything is running fine, except one thing...
When someone connects with nick like "punk'o'matic" I get error:
Code:

L 03/17/2005 - 14:34:04: [AMXX] Native error in "dbi_query" on line 141 (plugin "admin.amxx").
L 03/17/2005 - 14:34:04: [MYSQL] Invalid database handle -1
L 03/17/2005 - 14:34:04: [AMXX] Debug Trace =>
L 03/17/2005 - 14:34:04: [AMXX]      [0] Line 141, File "admin.sma"
L 03/17/2005 - 14:34:04: [AMXX]      [1] Line 208, File "admin.sma"
L 03/17/2005 - 14:34:04: [AMXX]      [2] Line 250, File "admin.sma"
L 03/17/2005 - 14:34:04: [AMXX] Native error in "dbi_num_rows" on line 156 (file "admin.sma").
L 03/17/2005 - 14:34:04: [MYSQL] Invalid result handle -6
L 03/17/2005 - 14:34:04: [AMXX] Native error in "dbi_free_result" on line 194 (file "admin.sma").
L 03/17/2005 - 14:34:04: [MYSQL] Invalid result handle -6
L 03/17/2005 - 14:34:04: [AMXX] Native error in "dbi_close" on line 195 (file "admin.sma").
L 03/17/2005 - 14:34:04: [MYSQL] Invalid database handle -1

The weird thing is that it does work, if someone connects with nick "I'm gay" or something (one quote only)...
I used to escape single quote characters, but then I realised that you cannot use double quotes in your nick, so I changed my query and now it looks like this:
Code:

format(query, 511, "SELECT `flags`,`access`,`password` FROM `admins` WHERE `name`=^"%s^"", name)
new Result:Res = dbi_query(sql, query)

It doesn't matter if I escape quotes with \ or not, it still doesn't work... but it works if I execute this query in mysql console screen

So, I guess this is some dbi bug or I'm doing something wrong?

BAILOPAN 03-17-2005 10:14

First off, I'd guess your plugin is lacking serious error checking. If you have a -1 connection handle and then try to execute more statements, it's obviously not going to work. Every single time you get a return value you should be checking it along the way.

As for the actual query, you should use server_print or something to dump it to the screen, to make sure it's being formatted correctly.

kexz 03-17-2005 10:42

ok i found the cause of the error... its `ip`... i skipped that, because i thought its not important :oops:

it is used as function parameter:
getAccess(id,name[],authid[],ip[], password[])

ip is used inside this function and is part of query:
dbi_query(sql, "SELECT ... ... (`auth`=^"%s^" AND INSTR(flags,'d')) ... ...", ip )

when i take out this part, there is no more errors...

im confused :?

updated.
this one crashes server instantly:
Code:

format(qry, 511, "SELECT `auth`,`password`,`access`,`flags` FROM `%s` WHERE (`auth`=^"%s^" AND INSTR(flags,'d'))", table, ip)
new Result:Res = dbi_query(sql, qry)


kexz 03-17-2005 11:32

hmmmmmmmmmm it doesn't even work if i execute following query:
Code:

  new theip[16]
  get_user_ip( id, theip, 15, 1)
  new Result:Res = dbi_query(sql, "SELECT `auth`,`password`,`access`,`flags` FROM `%s` WHERE (`auth`=^"%s^" AND INSTR(flags,'d'))", table, theip)

i get instant Segmentation fault
Code:

L 03/17/2005 - 18:29:09: "kexz<1><VALVE_ID_LAN><>" connected, address "192.168.0.2:27005"
./hlds_run: line 423: 21729 Segmentation fault      $HL_CMD
Add "-debug" to the ./hlds_run command line to generate a debug.log to help with solving this problem
Thu Mar 17 18:29:09 EET 2005: Server restart in 10 seconds
Thu Mar 17 18:29:14 EET 2005: Server Quit


kexz 03-17-2005 13:07

ok finally i found cause of all this...

whenever I try to execute query with params witch contains dot (like auth='ke.xz') and row exists, it crashes...

this only happens when I try to assing query results to Result:Res variable...

it MUST be dbi issue

kexz 03-17-2005 15:22

ok after 4 hours of experimenting, i finally got a solution... actually it wasnt Result:Res problem, but dbi_result

after getting first param `auth` ( dbi_result(Res,"auth", qAuth, 31) ) i could not read second one, which is password, nor third or fourth (access, flags)...

the thing is that dbi_field() works perfectly... but WHY?!?!?!


All times are GMT -4. The time now is 13:57.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.