내가 프로젝트에 대한 PDO를 사용하고 있습니다하지만 난 제출에 구문 오류가 있습니다 PDO :는 ... 여기 내 코드 구문 오류
<?php
require_once('_database.php');
$titre = $_POST['titre'];
$text = $_POST['text'];
$date = date("Y-m-d");
try
{
// Insertion dans la base de donnée
$requete = $connexion->exec("INSERT INTO article (id, idAuteur, titre, text, date) VALUES (0, 0, $titre, $text, $date)");
if (!$requete) {
echo "\nPDO::errorInfo():\n";
print_r($connexion->errorInfo());
echo $requete;
}
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
?>
그리고 이것은 내가 내 브라우저에서 무엇을 가지고 있습니다 :
내가 뭔가를 분명 잊어 버린하지만 볼 수없는 가정PDO::errorInfo(): Array ([0] => 42000 [1] => 1064 [2] => 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 '
Your contentrgrgrg
, 2013-12-18)' at line 1)
...
왜 준비된 문을 무시하면 PDO를 사용합니까? – Mihai
SQL을 생성 할 때 자리 표시 자 및 바운드 변수를 사용해야합니다. – andrewsi