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 

[SOLVED]What is wrong here

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


Joined: 23 Sep 2006
Posts: 270
Location: /dev/null

PostPosted: Sun Jul 13, 2014 8:52 am    Post subject: [SOLVED]What is wrong here Reply with quote

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
View user's profile Send private message MSN Messenger
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Jul 13, 2014 12:21 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Fire-Fox
Master


Joined: 23 Sep 2006
Posts: 270
Location: /dev/null

PostPosted: Sun Jul 13, 2014 2:07 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Sun Jul 13, 2014 5:19 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Fire-Fox
Master


Joined: 23 Sep 2006
Posts: 270
Location: /dev/null

PostPosted: Mon Jul 14, 2014 6:22 am    Post subject: Reply with quote

What will give me my login to the database Smile

I'll post my setup when i get it to work Smile
_________________
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
Back to top
View user's profile Send private message MSN Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Jul 14, 2014 2:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
Fire-Fox
Master


Joined: 23 Sep 2006
Posts: 270
Location: /dev/null

PostPosted: Mon Jul 14, 2014 7:23 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Jul 15, 2014 3:30 am    Post subject: Reply with quote

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
View user's profile Send private message
Fire-Fox
Master


Joined: 23 Sep 2006
Posts: 270
Location: /dev/null

PostPosted: Tue Jul 15, 2014 4:12 am    Post subject: Reply with quote

Ahh thanks Smile
_________________
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
Back to top
View user's profile Send private message MSN Messenger
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