Insert into MySQL Table PHP

后端 未结 5 891
悲&欢浪女
悲&欢浪女 2021-01-13 22:37

I am having some trouble making a simple form to insert data into a MySQL table. I keep getting this SQL error:

\"Error: You have an error in your SQL

5条回答
  •  花落未央
    2021-01-13 23:08

    ?php
      $conn=new mysqli("localhost","root","","inventory")
      or die("not connected".mysqli_connect_error());
      if(isset($_POST['submit']{
        $ItemNumber=$_POST['ItemNumber'];
        $Stock=$_POST['Stock'];
        $sql="insert into current stock(ItemNumber,Stock) values('$ItemNumber','$Stock')";
        $query=mysqli_query($conn,$sql);
        if($query){
          echo"1 row inserted";
        }else{
          echo mysqli_error($conn);
        }
      }
    ?>
    

提交回复
热议问题