If you do not provide an explicit return value using the "return" command, your proc will exit with the return value of the last successful command within the proc (not counting conditional constructs themselves).
Your code is however somewhat confusing; is $result a list of matching records, or is it the number of records returned?
This suggests $result is the number of records returned from your query (being an integer).
Code: Select all
set username [lindex [split $result] 0]
This however suggests that $result is a resultset from your query, with each field being whitespace separated (ie. not a proper tcllist). I am not familiar with the -list parameter for mysqlsel, but from what I can tell from resources on the net, it makes mysqlsel return a list of lists. Hence, split should
NOT be used here.
From the bits and pieces I've managed to gather from your script and mysqltcl, I guess you should have something like this:
Code: Select all
proc invite_me { nick host handle text } {
global db_handle staffchan
set sql "SELECT username, irc FROM users WHERE username='$nick'"
set result [mysqlsel $db_handle $sql -list]
if {[llength $result] > 0} {
set username [lindex [lindex $result 0] 0]
set password [lindex [lindex $result 0] 1]
}
....
}