I have been trying to fix this problem for several hours and donโt know why this is not working. I am trying to send an http message with a Qt application and use this as my php script:
<?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);
?>
I was at some point until the moment when I was getting success, but then the values โโdid not actually show up in my db. Thanks, David
source
share