Im having some trouble with the following code that my tutor had provided however ive been having some trouble with getting it working.
Im getting this error:
"invalid object or resource mysqli_stmt"
This is my code, it grabs the data from a text input from a previous html file that this PHP file is assigned to, it should then send the data to my database:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
//Report all errors or strict errors
//<USERNAME> and <PASSWORD> are temporary for this post.
$database = mysqli_connect("localhost", "<USERNAME>", "<PASSWORD>") or
die ('Unable to connect. Check connection params');
$userName = $_POST['userName'];
$password = $_POST['password'];
$emailAddress = $_POST['emailAddress'];
if ($database != FALSE)
{
print "Connection to the database made successfully.";
echo $userName;
echo $password;
echo $emailAddress;
$query = "INSERT INTO customerData(userName, password, emailAddress) VALUES (?,?,?)";
$stmt = mysqli_stmt_init($database);
mysqli_stmt_prepare($stmt, $query);
mysqli_stmt_bind_param($stmt, 'isii', $userNamename, $password, $emailAddress);
mysqli_stmt_execute($stmt);
print "user added.";
}
?>