Well I have the following error, that when I try to register data in the database I get the following error
Error: 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 '' ARTICLE CODE ',' SECTION ',' NAMEBREAK ',' PRICE ',' DATE ',' IMPORTED 'at line 1 On Line 36
It turns out that the error lies in Line 36 because of some syntax error problem in the SQL statement but I have been trying to find it for a while and I can not find anything, besides that if it were for the fields of the DB neither because the fields are:
$c_articulo=$_POST["c_articulo"];
$seccion=$_POST["seccion"];
$n_art=$_POST["nombre_articulo"];
$precio=$_POST["precio"];
$fecha=$_POST["fecha"];
$importado=$_POST["importado"];
$p_origen=$_POST["p_origen"];
try {
$base=new PDO("mysql:host=localhost;dbname=pruebas", "root", "");
$base->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$base->exec("SET CHARACTER SET utf8");
$sql= "INSERT INTO PRODUCTOS ('CÓDIGOARTÍCULO', 'SECCIÓN', 'NOMBREARTÍCULO', 'PRECIO', 'FECHA', 'IMPORTADO', 'PAÍSDEORIGEN') VALUES (:c_articulo, :seccion, :n_art, :precio, :fecha, :importado, :p_origen)";
$resultado = $base->prepare($sql);
$resultado->execute(array(":c_articulo"=>$c_articulo, ":seccion"=>$seccion, ":n_art"=>$n_art, ":precio"=>$precio, ":fecha"=>$fecha,":importado"=>$importado, ":p_origen"=>$p_origen));
echo "Hemos insertado el registro";
$resultado->closeCursor();
}
catch(Exception $e){
die ("Error: " . $e->GetMessage() . " En la Linea " . $e->getline());
}
Form code to insert the data:
<form action="pagina_busqueda_pdo.php" method="post" accept-charset="utf-8">
<table>
<tr><td><label>C.Artículo<input type="text" name="c_articulo" placeholder="Código Articulo"></label></td></tr>
<tr><td><label>Seccion<input type="text" name="seccion" value=""></label></td></tr>
<tr><td><label>Nombre Art<input type="text" name="nombre_articulo" value=""></label></td></tr>
<tr><td><label>Precio<input type="text" name="precio" value=""></label></td></tr>
<tr><td><label>Fecha<input type="text" name="fecha" value=""></label></td></tr>
<tr><td><label>¿Importado?<input type="text" name="importado" value=""></label></td></tr>
<tr><td><label>Pais de Origen<input type="text" name="p_origen" value=""></label></td></tr>
<tr><td><input type="submit" name="enviar" value="Enviar"></td></tr>
</table>