PHP - Erreur lors de l'insertion vers mysql

Résolu
PHPFANParis -  
 PHPFANParis -
Bonjour,

Voici l'erreur que j'ai lorsque j'essaie d'inserer dans ma table mysql

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 'long, region, cp, validation, codevalidation) VALUES('', 'fdsg', 'iunsqdn', 'iun' at line 1' in /homepages/36/d416472629/htdocs/000089/test.php:27 Stack trace: #0 /homepages/36/d416472629/htdocs/000089/test.php(27): PDOStatement->execute(Array) #1 {main} thrown in /homepages/36/d416472629/htdocs/000089/test.php on line 27

Voici mon code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>

<body>
<?php
$login = "fdsg";
$password = "iunsqdn";
$email = "iunsqdn";
$nom = "iunsqdn"; 
$prenom = "iunsqdn";
$ville = "iunsqdn"; 
$adresse = "iunsqdn"; 
$lat = "iunsqdn"; 
$long = "iunsqdn"; 
$region = "iunsqdn"; 
$cp = "iunsqdn"; 
$validation = "iunsqdn"; 
$codevalidation = "iunsqdn";

	$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
	$bdd = new PDO('mysql:host=localhost;dbname=mybase', 'root', '', $pdo_options);
					$req = $bdd->prepare('INSERT INTO member (login, password, email, nom, prenom, ville, adresse, lat, long, region, cp, validation, codevalidation) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
    				$req->execute(array($login, $password, $email, $nom, $prenom, $ville, $adresse, $lat, $long, $region, $cp, $validation, $codevalidation));
					?>
</body>
</html>


PS : Ma base de données est hebergée chez 1&1.

Merci d'avance.
A voir également:

1 réponse

maka54 Messages postés 698 Date d'inscription   Statut Membre Dernière intervention   80
 
c'est ton champ"long" qui pose problème, c'est un mot réservé, soit tu le changes de nom, soit tu mets des quotes (alt gr + 7)
2
PHPFANParis
 
Merci beaucoup, c'est résolu !
0