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.
Help for those learning Tcl or writing their own scripts.
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Sun Jul 13, 2014 8:52 am
can't read "info": no such variable
Code: Select all
proc infoDel {nick uhost handle chan text} {
if {![channel get $chan infoDel]} return
variable dbInfo
if {[scan $dbInfo %s%s%s%s hostname username password database] != 4} return
set info [::mysql::escape $info]
set con [::mysql::connect -host $hostname -user $username -password $password -db $database]
set query [::mysql::query $con "SELECT info FROM info WHERE info = '$info'"]
if {[::mysql::fetch $query]==""} {
putquick "PRIVMSG $chan : Nothing found"
} else {
set query [::mysql::query $con "SELECT info FROM info WHERE info = '$info'"]
putquick "PRIVMSG $chan :Info list $info"
}
::mysql::endquery $con
::mysql::close $con
}
Last edited by
Fire-Fox on Mon Jul 14, 2014 7:24 pm, edited 1 time in total.
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sun Jul 13, 2014 12:21 pm
Believe this would be the problem line...
You are trying to read
$info before it exists.
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Sun Jul 13, 2014 2:07 pm
Hey!
I have tried to put various places but havn't worked yet
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sun Jul 13, 2014 5:19 pm
Exactly what information are you trying to send to the
::mysql::escape proc?
I'm sure it's not the contents of
$info because that variable does not exist yet.
Maybe you mean something more like...
Code: Select all
set info [::mysql::escape $dbInfo]
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Mon Jul 14, 2014 6:22 am
What will give me my login to the database
I'll post my setup when i get it to work
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Mon Jul 14, 2014 2:23 pm
There's no need to escape your dbInfo variable cos that's considered safe so no need to sanitize it but rather the user input.
The error clearly states where's the problem and SpiKe^^ highlighted that in his first post.
Once the game is over, the king and the pawn go back in the same box.
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Mon Jul 14, 2014 7:23 pm
Here is the working version
Code: Select all
bind pub -|- !info infolist
proc infolist {nick uhost handle chan text} {
if {![channel get $chan infoList]} return
variable dbInfo
if {[scan $dbInfo %s%s%s%s hostname username password database] != 4} return
set con [::mysql::connect -host $hostname -user $username -password $password -db $database]
set query [::mysql::query $con "SELECT info FROM infos"]
if {[::mysql::fetch $query]==""} {
putquick "PRIVMSG $chan : \0034Nothing found! :-(\003"
} else {
set query [::mysql::query $con "SELECT info FROM infos ORDER BY info"]
::mysql::map $query { info } {
putquick "PRIVMSG $chan :\0037INFO\003: \0039$info\003"
}
::mysql::endquery $con
::mysql::close $con
}
}
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Tue Jul 15, 2014 3:30 am
The:
Code: Select all
::mysql::endquery $con
::mysql::close $con
need to be moved one section down cos as are right now are in the else section.
Also, you can replace the first query with the second one that you should remove entirely.
Code: Select all
bind pub -|- !info infolist
proc infolist {nick uhost handle chan text} {
if {![channel get $chan infoList]} return
variable dbInfo
if {[scan $dbInfo %s%s%s%s hostname username password database] != 4} return
set con [::mysql::connect -host $hostname -user $username -password $password -db $database]
set query [::mysql::query $con "SELECT info FROM infos ORDER BY info"]
if {[::mysql::fetch $query]==""} {
putquick "PRIVMSG $chan : \0034Nothing found! :-(\003"
} else {
::mysql::map $query { info } {
putquick "PRIVMSG $chan :\0037INFO\003: \0039$info\003"
}
}
::mysql::endquery $con
::mysql::close $con
}
Once the game is over, the king and the pawn go back in the same box.
Fire-Fox
Master
Posts: 299 Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null
Post
by Fire-Fox » Tue Jul 15, 2014 4:12 am
Ahh thanks