| View previous topic :: View next topic |
| Author |
Message |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Sun Jul 13, 2014 8:52 am Post subject: [SOLVED]What is wrong here |
|
|
can't read "info": no such variable
| Code: |
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
}
|
_________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze
Last edited by Fire-Fox on Mon Jul 14, 2014 7:24 pm; edited 1 time in total |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Jul 13, 2014 12:21 pm Post subject: |
|
|
Believe this would be the problem line... | Code: | | set info [::mysql::escape $info] |
You are trying to read $info before it exists. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Sun Jul 13, 2014 2:07 pm Post subject: |
|
|
Hey!
I have tried to put various places but havn't worked yet _________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Jul 13, 2014 5:19 pm Post subject: |
|
|
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: | | set info [::mysql::escape $dbInfo] |
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Mon Jul 14, 2014 6:22 am Post subject: |
|
|
What will give me my login to the database
I'll post my setup when i get it to work  _________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Jul 14, 2014 2:23 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Mon Jul 14, 2014 7:23 pm Post subject: |
|
|
Here is the working version
| Code: |
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
}
}
|
_________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Jul 15, 2014 3:30 am Post subject: |
|
|
The:
| Code: |
::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: |
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. |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Tue Jul 15, 2014 4:12 am Post subject: |
|
|
Ahh thanks  _________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
|