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 

errh??

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


Joined: 03 Dec 2004
Posts: 3

PostPosted: Fri Dec 03, 2004 6:57 pm    Post subject: errh?? Reply with quote

My problem is that my script won't enter my foreach-loop if there is no user with nick=$nick. Wich means that my if-statement is useless. Is there some way to transform my foreach to a combined if-statement that does what my if-statement should do?
In PHP i would have checked if number of results from the query is larger than zero, but I can't find a manualpage for mysqltcl that mentions this kind of function.
Code:

   foreach query [mysqlsel $mysql(conn) "SELECT nick FROM users WHERE nick='$nick' ORDER BY nick LIMIT 1" -list] {
      set test "[lindex $query 0]"
      if { $test eq "" } {
         set mysql(conn) [mysqlconnect -user $mysql(user) -password $mysql(pass) -db $mysql(data)]
         mysqlexec $mysql(conn) "INSERT INTO $mysql(table) ('nick' , 'uname') VALUES ('$nick','$uhost')"
      # SOME NICE OUTPUT THAT SAYS: This is how u register.
      } else {
      # SOME NICE OUTPUT THAT SAYS: You are already registered
      }
   }


*Happy hugs*
Cut-n-paste-o-mania
Back to top
View user's profile Send private message Send e-mail
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Dec 03, 2004 10:38 pm    Post subject: Reply with quote

Code:

set resultset [mysqlsel $mysql(conn) "SELECT nick FROM users ...]
if {$resultset == {}} {
# not found in db, register/insert follows
#
} else {
# found in db, loop through result set
  foreach result $resultset {
  # use $result
  }
}
Back to top
View user's profile Send private message Visit poster's website
T-Xorcist
Halfop


Joined: 14 Nov 2005
Posts: 47
Location: Netherlands

PostPosted: Thu May 11, 2006 6:26 pm    Post subject: Reply with quote

I try this:
Code:
package require mysqltcl
set mysql(conn) [mysqlconnect -user user -db tbot -password pass]
foreach name [mysqlsel $mysql(conn) "SELECT name FROM channels" -list] {
  putquick "PRIVMSG $chan :$name "
}
mysqlclose $mysql(conn)


There are 3 records in the database, but it only displays one, not all.
What am I doing wrong? Crying or Very sad

Please help, I am trying 3 days now to get it done, but I just can't Crying or Very sad

I tried this aswell:
Code:
set query1 [mysqlquery $mysql(conn) {SELECT name FROM channels}]
while {[set row [mysqlnext $query1]]!=""} {
  set name [lindex $row 0]
  putquick "PRIVMSG $chan :$name"
}
mysqlendquery $query1


Doesn't work either! Is it my mysqltcl maybe? I run FreeBSD by the way.

It only displays the 1st record, not all 3

Please help me Embarassed and let me know if the scripts are good.
_________________
is-1337.org IRC server!
Back to top
View user's profile Send private message Visit poster's website
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