Erreur incompréhensible : 'SQLSTATE[42000]: Syntax error or access violation: 1064'
	
	
		Bonjour à tous,
Voilà, je me tire les cheveux depuis 2 jours sur un problème d'insertion en table.
Ci-dessous, deux fonctions: l'une marche, l'autre pas...
Je n'ai pas d'erreur PHP en logs.
errorInfo renvoie pour chacune : Array([0]=>00000)
(Maj. J'ai mis ensuite le code erreur PDO... Je dois avoir un truc dans les yeux, c'est possible!)
insertAnswer() fonctionne, insertQuestion() non. Et je ne comprends pas...
Si ça se trouve il y a un truc gros comme un camion sous mes yeux trop las.
D'avance merci !
	Code:
	
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
   |  
function insertAnswer() {
 
	$dbh = DBHandler::getInstance();
 
	$user			= 1;
	$current_question	= 2;
	$question		= 2;
	$date			= date("Y-m-d H:m:s");;
	$period			= 'xxxx';
	$answer			= 'toto';
 
	$sql = "INSERT INTO vto_answers (user_id, question_id, date, period, answer) VALUES ( :user_id, :question_id, :date, :period, :answer)";
	$stmt = $dbh->prepare($sql);
 
	$stmt->execute(array(':user_id'=>$user, ':question_id'=>$question, ':date'=>$date, ':period'=>$period, ':answer'=>$answer));
 
	print_r($dbh->errorInfo());
 
	DBHandler::closeConnection();
 
}
 
function insertQuestion() {
 
	$dbh = DBHandler::getInstance();
 
	$order		= 1;
	$label		= 'toto';
	$type		= 'SingleLineText';
	$meta		= 'test';
	$group_id 	= 1;
 
	$sql = "INSERT INTO vto_questions (order, label, type, meta, group_id) VALUES (:order, :label, :type, :meta, :group_id)";
	$stmt = $dbh->prepare($sql);
 
	$stmt->execute(array(':order'=>$order, ':label'=>$label, ':type'=>$type, ':meta'=>$meta, ':group_id'=>$group_id));
 
	print_r($dbh->errorInfo());
 
	DBHandler::closeConnection();
} | 
 
	Code:
	
1 2 3 4 5 6 7
   |  
PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 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 'order, label, type, meta, group_id) VALUES ('1', 'toto', 'SingleLineText', 'test' at line 1' in ~/htdocs/temp.php:39
Stack trace:
#0 ~/htdocs/temp.php(39): PDOStatement->execute(Array)
#1 ~/htdocs/temp.php(46): insertQuestion()
#2 {main}
  thrown in ~/htdocs/temp.php on line 39 |