1

我试图仅在 if 内部返回所需值时才显示 if 语句的内容。但是这不起作用,所以我想这不是你在 TCL 中的做法。任何意见,将不胜感激。

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."
}
4

1 回答 1

5

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
}
于 2014-02-01T00:06:05.810 回答