2017-09-30 1 views
-1

過去2時間、私のコードを実行するのに苦労しました。しかし、私は私のSQLクエリで構文エラーを持って誰も私を助けることができますか?未知PDOException:SQLSTATE [42000] - データの挿入を試みよう

マイコード:

$query = "INSERT INTO `article` (`text`,`headline`,`date`,`author`,`active`) SET (?,?,?,?,?)"; 
$stmt = $pdo->prepare($query); 
$stmt->bindValue(1, $text, PDO::PARAM_STR); 
$stmt->bindValue(2, $headline, PDO::PARAM_STR); 
$stmt->bindValue(3, $date, PDO::PARAM_STR); 
$stmt->bindValue(4, $author, PDO::PARAM_STR); 
$stmt->bindValue(5, $active, PDO::PARAM_INT); 
if($stmt->execute()) { //do something } 

致命的なエラー:ところで

Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SET ('some text','test headline','2017-09-30','author123',1)'

、どのように私はPHPコードタグを使うことができますか?

おかげ

答えて

-1

はあなたのクエリに「VALUES」の「SET」を変更してみてください、「SET」のご利用には、そのコンテキストで間違っています。

関連する問題