I have a table with 5 columns where the first column is a primary key and has a Auto_INCREMENT attribute. I am trying to insert a row into the table using the following code:
<?php
include "DBConstants.php";
$db = new DBConstants();
$connection = new mysqli($db->SERVER_NAME,$db->DB_USERNAME,$db->DB_PASSWORD,$db->DB_NAME);
$query = "INSERT INTO mailinglist (email, validationID, usRequest, isValidated) VALUES (?,?,?,?)";
$statement = $connection->prepare($query);
$email = $_GET["email"];
$validationID = openssl_random_pseudo_bytes ( 10, $crstrong);
$usRequest=false;
$isValidated = false;
$statement->bind_param($email,$validationID,$usRequest,$isValidated);
$statement->execute();
$statement->close();
$connection->close();
$array = array("result"=>true,"message"=>"You have successfully subscribed");
echo json_encode($array);
?>
But I am getting a warning like this:
Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables
And hence the table is not being updated. Where am I going wrong?