我在mysql中收到错误可以帮助我吗?

时间:2016-12-25 15:56:05

标签: php mysql sql syntax-error

我收到此错误:

  

UPDATE主题SET menu_name ='删除我',位置= 4,可见= 1,WHERE id = 6数据库查询失败:您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第1行的“WHERE id = 6”附近使用正确的语法

SUB login
    OPEN "USERPASS.TXT" FOR INPUT AS #2
    CLS
    97
    LOCATE 2, 30: PRINT "LOGIN"
    LOCATE 4, 10: INPUT "PLEASE ENTER CORRECT USERNAME OR PRESS B IF YOU WANT TO GO BACK"; USER$
    IF UCASE$(USER$) = "B" THEN
        CLOSE #2
        CALL menu
    ELSEIF UCASE$(USER$) <> "B" THEN
        WHILE NOT EOF(2)
            INPUT #2, U$, p$
            IF U$ = USER$ THEN
                TEMPUSER$ = U$
                PASSWORDS$ = p$
            END IF
        WEND
        IF USER$ = TEMPUSER$ THEN
            98
            PRINT PASSWORDS$
            LOCATE 5, 30: INPUT "ENTER PASSWORD OR PRESS B if you want to go back"; password$
            IF UCASE$(password$) = "B" THEN GOTO 97
            ELSEIF UCASE$(password$) <> "B" THEN
                IF password$ = PASSWORDS$ THEN
                    PRINT "HURRAY YOU LOGGED IN"
                ELSE
                    GOTO 98
                END IF
            END IF
        ELSE
            GOTO 97
        END IF

        CLOSE #2
END SUB

1 个答案:

答案 0 :(得分:2)

where之前有一个冗余逗号。删除它,你应该没问题:

$query  = "UPDATE subjects SET ";
$query .= "menu_name = '{$menu_name}', ";
$query .= "position = {$position}, ";
$query .= "visible = {$visible} ";
# Comma removed here ----------^
$query .= "WHERE id = {$id}";