title: How to insert post data into mysql db with php?
body: <p>I have been troubleshooting this for multiple hours and am not sure why this is not working. I am trying to send a http post with a Qt app and using this as my php script:</p>
  
  <pre><code>&lt;?php
  $con=mysqli_connect("*.mysql.eu2.*.com:3306","*****","****","****");
  
  if (mysqli_connect_errno($con))
  {
     echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  $id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
  $price = filter_input(INPUT_POST, 'price', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
  $type = filter_input(INPUT_POST, 'type', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
  $stock= filter_input(INPUT_POST, 'stock', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
  
    $currentid = mysqli_insert_id();
  
    if (trim($id) == '') {
      exit('id cannot be empty!');
    }
    if (trim($price) == '') {
      exit('price cannot be empty!');
    }
    if (trim($type) == '') {
      exit('type cannot be empty!');
    }
    if (trim($stock ) == '') {
      exit('stock cannot be empty!');
    }
  
    $result = "insert into ammo (ammoType,storeId,ammoStock,ammoPrice) VALUES ('".$type."','".$id."','".$stock."','".$price."');";
  
     mysqli_query($result) or die("Could not insert data");
  
  
  
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>I have been at a point before where I was getting success but then the values were not actually showing up in my db.
  Thanks,
  -David</p>