| View previous topic :: View next topic |
| Author |
Message |
UK10 Voice
Joined: 16 Jan 2006 Posts: 10
|
Posted: Sat Mar 28, 2009 9:03 am Post subject: mysqlquery: not mysqltcl handle |
|
|
Hi..need help thx
| Code: |
PREDB : Error connexion MySQL ! Tcl error [pub:addpre]: mysqlquery: not mysqltcl handle |
Tcl scripting
| Code: |
###############################
# Connexion à MySQL #
###############################
load libmysqltcl.dll
package require mysqltcl
if { [catch {mysqlstate $mysql_handler}] } {
if [catch {mysqlconnect -host $host -user $user -password $password -db $db} mysql_handler] {
putquick "PRIVMSG $chanadd :Error MySQL !!"
putlog "PREDB : Error connexion MySQL !"
}
} else {
putlog "PREDB: MYSQL connected !"
}
bind pub - !test pub:test
proc pub:test {nick uhost handle channel arg } {
global Hdecalage chanadd chanpre botnetkick1 prebotnick erreur
if { [catch {mysqlstate $mysql_handler}] } {
if [catch {mysqlconnect -host $host -user $user -password $password -db $db} mysql_handler] {
putlog "PREDB : Error MySQL !"
}
} else {
putlog "PREDB : Connect MySQL !"
}
|
|
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Mar 28, 2009 1:27 pm Post subject: |
|
|
First, the proc that caused the error is not included in the posted code.
Secondly, when you connect, you run the code in globalspace, so the database handle is stored in ::mysql_handler, yet atleast in pub:test, you are trying to use the localspace variable mysql_handler. Most likely, you forgot to link the localspace variable to the globalspace one (using the global command).
Same goes for several other variables in your pub:test proc. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
UK10 Voice
Joined: 16 Jan 2006 Posts: 10
|
Posted: Sat Mar 28, 2009 10:59 pm Post subject: |
|
|
| strange , before that running without modifications |
|
| Back to top |
|
 |
UK10 Voice
Joined: 16 Jan 2006 Posts: 10
|
Posted: Mon Mar 30, 2009 2:00 pm Post subject: |
|
|
| give me example about this code |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Mar 30, 2009 2:17 pm Post subject: |
|
|
Some examples regarding variable spaces then.
| Code: | set myvar 1
proc test1 {} {
putlog $::myvar
}
proc test2 {} {
putlog $myvar
}
proc test3 {} {
global myvar
putlog $myvar
}
proc test4 {} {
upvar #0 myvar test
putlog $test
putlog $myvar
}
proc test5 {} {
upvar #0 myvar test
putlog $test
putlog $::myvar
set myvar 2
putlog $myvar
putlog $::myvar
} |
The above shows a few working and non-working procs that try to access the globalspace variable ::myvar (set in the beginning of the script):
- test1 (works):
Here we access the variable using the full namespace path ::myvar
- test2 (not working):
Here we try to access the variable, but we leave out the namespace path. As such, instead we'll end up trying to access the local variable myvar, which does not exist. You'll end up with an error stating "No such variable".
- test3 (works):
Here we first use the global command, which will link the local variable myvar to the globalspace variable ::myvar. As a result, whenever we access myvar, we'll actually end up operating on ::myvar.
- test4 (works, but generates an error):
Here we first use the upvar command to link the local variable test with the globalspace variable ::myvar. The first putlog will work, as it accesses the now linked variable test. The second putlog will however fail, as there still is no local myvar variable.
- test5 (works):
Here we also link test with ::myvar, but it also illustrates how setting a local variable will not affect a globalspace one.
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
UK10 Voice
Joined: 16 Jan 2006 Posts: 10
|
Posted: Sat Apr 04, 2009 1:32 pm Post subject: |
|
|
| thank ; but don't work |
|
| Back to top |
|
 |
|