Here is the $_POST array :
Array
(
[car_id] => ford_ka
[marca] => Teste
[modelo] => Teste
[preco] => 123
[descricao] => otimo carro teste123
[tanque] => 123
[motor] => 320cv bom blablabla
)
So i pass it to variables
$c_id = filter_var($_POST["car_id"], FILTER_SANITIZE_STRING);
$marca = filter_var($_POST["marca"], FILTER_SANITIZE_STRING);
$modelo = filter_var($_POST["modelo"], FILTER_SANITIZE_STRING);
$preco = filter_var($_POST["preco"], FILTER_SANITIZE_NUMBER_INT);
$desc = filter_var($_POST["descricao"], FILTER_SANITIZE_STRING);
$tanque = filter_var($_POST["tanque"], FILTER_SANITIZE_NUMBER_INT);
$motor = filter_var($_POST["motor"], FILTER_SANITIZE_STRING);
I create my connection
$mysqli = new mysqli($mysql_host, $mysql_username, $mysql_password,$mysql_database);
if ($mysqli->connect_error) {
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
Then i prepare the data
$statement = $mysqli->prepare("INSERT INTO cars_data (car_id, marca, modelo, preco, descricao, tanque, motor) VALUES(?, ?, ?, ?, ?, ?, ?)");
Bind it to markers
$statement->bind_param('sssisis', $c_id, $marca, $modelo, $preco, $desc, $tanque, $motor);
And execute it
if($statement->execute()){
print "Your car with the id " . $c_id . "has been included";
}else{
print $mysqli->error;
}
}
So, what i'm not getting ?
UPDATE!!!
This is the message i got from the log: "PHP Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in C:\MAMP\htdocs\process.php:43 Stack trace: #0 {main} thrown in C:\MAMP\htdocs\process.php on line 43"