Reputation: 69
I'm trying to insert this info into my table serie
but nothing happens. I guess there's some mistake with the _POST's but i don't know what.
$consulta="INSERT INTO `serie` VALUES ('$_POST[id]','$_POST[nombre]','$_POST[genero]', '$_POST[valoracion]','$_POST[director]', '$_POST[reparto]', '$_POST[temporadas]', '$_POST[episodios]', '$_POST[año_emision]', '$_POST[pais]', '$_POST[cadena]', '$_POST[reseña]', '$_POST[trailer]', '$poster_grande')";`
Edit
I have also tried using
$consulta="INSERT INTO `serie` (id, nombre, genero, valoracion, director, reparto, temporadas, episodios, año_emision, pais, cadena, reseña, trailer, poster_grande, poster_pequeño, screenshot1, screenshot2, screenshot3, screenshot4, screenshot5, screenshot6, screenshot7, screenshot8) VALUES ('".$_POST['id']."','".$_POST['nombre']."','$genero', '$valoracion','".$_POST['director']."', '".$_POST['reparto']."', '".$_POST['temporadas']."', '".$_POST['episodios']."', '".$_POST['año_emision']."', '$pais', '".$_POST['cadena']."', '".$_POST['reseña']."', '".$_POST['trailer']."', '$poster_grande', '$poster_pequeño', '$screenshot1' , $screenshot2', '$screenshot3', '$screenshot4', '$screenshot5', '$screenshot6', '$screenshot7', '$screenshot8')";
Both with no success.
Edit
I found that I was missing a '
, and the problem has been solved.
Upvotes: 0
Views: 73
Reputation: 39466
You shouldn't be doing that anyway - use a prepared statement and bind the $_POST
data as parameters of that statement.
Here's an example of how to do that using PDO
:
$stmt = $pdo->prepare("INSERT INTO serie VALUES (:id,:nombre,:genero,:valoracion,:director,:reparto,:temporadas,:episodios,:año_emision,:pais,:cadena,:reseña,:trailer,:poster_grande)");
$stmt->execute(array(
":id" => $_POST['id'],
":nombre" => $_POST['nombre'],
":genero" => $_POST['genero'],
":valoracion" => $_POST['valoracion'],
":director" => $_POST['director'],
":reparto" => $_POST['reparto'],
":temporadas" => $_POST['temporadas'],
":episodios" => $_POST['episodios'],
":año_emision" => $_POST['año_emision'],
":pais" => $_POST['pais'],
":cadena" => $_POST['cadena'],
":reseña" => $_POST['reseña'],
":trailer" => $_POST['trailer'],
":poster_grande" => $poster_grande
));
Upvotes: 0
Reputation: 311
$consulta = "INSERT INTO serie
(columnname1,columnname2,columnname3) VALUES (value1,value2,value3)";
Upvotes: 0
Reputation: 28753
Try with
$consulta="INSERT INTO `serie` VALUES ('".$_POST['id']."','".$_POST['nombre']."')";
You need to put the keys of the $_POST
in quotes and better to follow the standard insert query as well like
INSERT INTO tableName (col1,col2) VALUES (val1,val2)
Bec may some conflicts occurs when you have primary keys,auto increments are present in your table.
Upvotes: 2