egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

mysqlquery: not mysqltcl handle

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
UK10
Voice


Joined: 16 Jan 2006
Posts: 10

PostPosted: Sat Mar 28, 2009 9:03 am    Post subject: mysqlquery: not mysqltcl handle Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Mar 28, 2009 1:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
UK10
Voice


Joined: 16 Jan 2006
Posts: 10

PostPosted: Sat Mar 28, 2009 10:59 pm    Post subject: Reply with quote

strange , before that running without modifications
Back to top
View user's profile Send private message
UK10
Voice


Joined: 16 Jan 2006
Posts: 10

PostPosted: Mon Mar 30, 2009 2:00 pm    Post subject: Reply with quote

give me example about this code
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Mar 30, 2009 2:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
UK10
Voice


Joined: 16 Jan 2006
Posts: 10

PostPosted: Sat Apr 04, 2009 1:32 pm    Post subject: Reply with quote

thank ; but don't work
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber