0

i updated my code still not inserting , and i still need help :(

$reference=$_POST['reference'];
$description=$_POST['description']; 
$marque=$_POST['marque'];
$quantite=$_POST['quantite'];
$type=$_POST['type']; 
$id_s_equip=88; 
$insert="insert into piece (design_piece, type, marque, qte, id_s_equip,description) VALUES ( ?,?,?,?,?,?)";
$stmt = mysqli_prepare($c, $insert); 
mysqli_stmt_bind_param($stmt,'ssisis',$reference,$marque,$quantite,$type,
$id_s_equip,$description);
mysqli_stmt_execute($stmt); 
print(mysqli_stmt_affected_rows($stmt));
  • You aren't checking for errors. Strings need to be quoted and you are open to SQL injections. http://php.net/manual/en/mysqli.error.php The `.`s here `.$quantite.` also aren't concatenating. – chris85 Mar 01 '16 at 18:40
  • please read here and see if it helps http://stackoverflow.com/questions/35655450/mysqli-not-inserting-on-php/35656475#35656475 – Cârnăciov Mar 01 '16 at 18:59
  • i tried this instead but i still can't make it add records in my table `$reference=$_POST['reference']; $description=$_POST['description']; $marque=$_POST['marque']; $quantite=$_POST['quantite']; $type=$_POST['type']; $id_s_equip=88; $insert="insert into piece (design_piece, type, marque, qte, id_s_equip, description) VALUES ( ?,?,?,?,?,?)"; $stmt = mysqli_prepare($c, $insert); mysqli_stmt_bind_param($stmt, 'ssisis', $reference,$marque,$quantite,$type,$id_s_equip,$description); mysqli_stmt_execute($stmt); print(mysqli_stmt_affected_rows($stmt));` – HvíturFirvaldur Pétale Perdue Mar 01 '16 at 19:15
  • Update the question with your code and describe what happens with this code. Are you checking for errors now? – chris85 Mar 01 '16 at 19:22
  • i changed my code above @chris85 – HvíturFirvaldur Pétale Perdue Mar 01 '16 at 19:35

0 Answers0