This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

mysqlquery: not mysqltcl handle

Help for those learning Tcl or writing their own scripts.
Post Reply
U
UK10
Voice
Posts: 10
Joined: Mon Jan 16, 2006 12:30 pm

mysqlquery: not mysqltcl handle

Post by UK10 »

Hi..need help thx

Code: Select all

PREDB : Error connexion  MySQL ! Tcl error [pub:addpre]: mysqlquery: not mysqltcl handle
Tcl scripting

Code: Select all


###############################
# 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 !"
}
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
U
UK10
Voice
Posts: 10
Joined: Mon Jan 16, 2006 12:30 pm

Post by UK10 »

strange , before that running without modifications
U
UK10
Voice
Posts: 10
Joined: Mon Jan 16, 2006 12:30 pm

Post by UK10 »

give me example about this code
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Some examples regarding variable spaces then.

Code: Select all

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
U
UK10
Voice
Posts: 10
Joined: Mon Jan 16, 2006 12:30 pm

Post by UK10 »

thank ; but don't work
Post Reply