(PHP)(SQL)INSERT INTO的语法有什么问题?

时间:2015-09-02 03:10:00

标签: php sql insert

[1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1] in EXECUTE("INSERT INTO mailer_recipients (status,send_result_id) VALUES (,)")

public function saveData($status, $resultId)
{
    global $dbwriter;

    // Update send result, send result ID, status
    $sql = 'UPDATE ' . $this->recipientDbTable . ' SET ' . $this->recipientDbColumn['status'] . "='$status' WHERE " . $this->recipientDbColumn['id'] . '=' . $this->getId();
    $sql = 'UPDATE ' . $this->recipientDbTable . ' SET ' . $this->recipientDbColumn['result_id'] . "='$resultId' WHERE " . $this->recipientDbColumn['id'] . '=' . $this->getId();

    $sql = 'INSERT INTO ' . $this->recipientDbTable;
    $sql .= ' (' . $this->recipientDbColumn['status'] . ',' . $this->recipientDbColumn['result_id'] . ')';
    $sql .= ' VALUES ' . '(' . $status . ',' . $resultId . ')';

    $result = $dbwriter->execute($sql);

}

UPDATE很好。不知道是什么问题。

1 个答案:

答案 0 :(得分:1)

阅读您的错误消息。您的SQL以VALUES (,)结尾,这是无效的语法。显然,$status$resultId为空(''null或其他评估为空字符串的值。)