Issue
This Content is from Stack Overflow. Question asked by lele anayouss
I’m working on this project where i make a page online you can add ,update and show products on , and I’m trying to update a product in this table called ‘livre’ through the code down below ,but its not happening, I tried this code before on another table and it worked but this time i cant figure out the problem I keep getting the message “Erreur!! La modification a échoué.”,please help me find the error.
$the_photo=file_get_contents($_FILES['photo']['tmp_name']);
if(empty($_POST["code_l"]) || empty($_POST["titre"])||
empty($_POST["aut"]) || empty($_POST["an_edi"]) ||
empty($_POST["edit"]) || empty($the_photo) || empty($_POST["code_la"]) ||
empty($_POST["cdom"]))
{
echo' Il faut saisir un code <br/>';
}
else
{
$code=$_POST["code_l"];
$titre=$_POST["titre"];
$aut=$_POST["aut"];
$an_edi=$_POST["an_edi"];
$edit=$_POST["edit"];
if(isset($_FILES["photo"])){
$photo = file_get_contents ($_FILES["photo"]['tmp_name']);
}
$code_la=$_POST["code_la"];
//
$cdom=$_POST["cdom"];
try{
$sql = "UPDATE livre set code_livre='".$code."',titre='".$titre."', auteur='".$aut ."',
anneé_editionint='".$an_edi."',
editeur='".$edit."',photo='".addslashes($photo)."',code_langue='".$code_la."',
code_domaine='".$cdom."' WHERE code_livre=".$code;
$requete = $conx->prepare($sql);
$stmt=$requete->execute();
if($stmt === false)
{
die("Erreur!! La modification a échoué.");
}
else
{ header("location:lister_livre.php") ; }
}
catch (PDOException $e)
{
echo $e->getMessage();
}
}
”’
Solution
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.
This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.