插入数据库不起作用

问题描述 投票:0回答:1

当我想从 PHP 表单向我的库插入一些数据时遇到问题。 这是我的代码:

<?php
$ref=$_POST['ref'];
$desig=$_POST['desig'];
$ht=$_POST['ht'];
$ttc=$_POST['ttc'];
$prixfttc=$_POST['prixfttc'];
$qte=$_POST['qte'];
$rabais=$_POST['rabais'];
$caract=$_POST['caract'];
$img=$_POST['img'];


$connexion=mysqli_connect("localhost","root","","artimaroc");
$query="INSERT INTO artimaroc.produits (`REF`,`DESIGNATION`,`HT`,`TTC`,`pfttc`,`qte`,`rabais`,`caracteristique`,`image`)
VALUES ('$ref','$desig','$ht','$ttc','$prixfttc','$qte','$rabais','$caract','$img')";
$rep=mysqli_query($connexion,$query);
if($rep==true) echo "done";

 ?>

here is a picture of the attributes of my table where I want to insert

php mysql mysqli
1个回答
0
投票

这是代码

<?php
$ref=$_POST['ref'];
$desig=$_POST['desig'];
$ht=$_POST['ht'];
$ttc=$_POST['ttc'];
$prixfttc=$_POST['prixfttc'];
$qte=$_POST['qte'];
$rabais=$_POST['rabais'];
$caract=$_POST['caract'];
$img=$_POST['img'];


$connexion=mysqli_connect("localhost","root","","artimaroc");
$query="INSERT INTO artimaroc.produits (`REF`,`DESIGNATION`,`HT`,`TTC`,`pfttc`,`qte`,`rabais`,`caracteristique`,`image`)
VALUES ('$ref','$desig','$ht','$ttc','$prixfttc','$qte','$rabais','$caract','$img')";
$rep=mysqli_query($connexion,$query);
if($rep==true) echo "done";

 ?>

© www.soinside.com 2019 - 2024. All rights reserved.