1
votes

I'm trying to make display the contents of a if statement only if the if inside which is it, is returning the desired value. However this doesn't work, so I guess it's not how you do it in TCL. Any advice would be appreciated.

if {$firstq == 1} {
set sql "SELECT * FROM users WHERE username='$text' AND ircban='yes' LIMIT 1"
set result [mysqlsel $db_handle $sql]
    if{$result == 1} {
        putquick "NOTICE $nick :User is banned."
    } elseif{$result == 0} {
        putquick "NOTICE $nick :User is not banned."
}
1
This is a script for an eggdrop bot right? I'm asking just for tagging purposes. - Jerry
You'll find programming much easier if you use conventional indentation. - Donal Fellows

1 Answers

5
votes

You are missing a closing brace after the elseif and you need spaces after if and elseif:

if {$firstq == 1} {
    set sql "SELECT * FROM users WHERE username='$text' AND ircban='yes' LIMIT 1"
    set result [mysqlsel $db_handle $sql]
    if {$result == 1} { ;# <-- Need space after if
        putquick "NOTICE $nick :User is banned."
    } elseif {$result == 0} { ;# <-- Need space after elseif
        putquick "NOTICE $nick :User is not banned."
    } ;# <-- Missing closing brace
}