簡體   English   中英

(PHP) (SQL) INSERT INTO 的語法有什么問題?

[英](PHP) (SQL) What is wrong with the syntax of INSERT INTO?

[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 沒問題。 說不清是什么問題。

閱讀您的錯誤消息。 您的 SQL 以VALUES (,)結尾,這是無效的語法。 顯然, $status$resultId是空的( ''null或其他評估為空字符串的值)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM