This question already has an answer here:
So I'm having the same problem for 3 hours straight and I've been searching Stack Overflow, Google and even Bing (yes even Bing..) for the right answer but I can't seem to find a solution...
The problem:
I try to insert data into my database using a prepared statement, but I keep getting the same error over and over again. I'm using everything in the right order and stuff so that's not the mistake...
My code:
//INCLUDES FILES THAT HOLD ALL DATA (servername, username, ...)
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// prepare and bind
$stmt = $conn->prepare("INSERT INTO REGISTRY (user_ref, email_user, date_created, title, tweet, description, category, filename, invoice) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sssssssss", $gebruikerID, $email, $date_created, $title, $tweet, $description, $category, $nameImage, $customUniqueId);
// set parameters and execute
$gebruikerID = $gebruikerID;
$email = $email;
$date_created = date("d/m/Y H:i:s");
$title = date("d/m/Y H:i:s");
$tweet = $_POST["tweet"];
$description = $_POST["project_description"];
$category = $_POST["category"];
$nameImage = $nameImage;
$customUniqueId = $_GET["redirect"];
$stmt->execute();
echo "New records created successfully";
$stmt->close();
$conn->close();
The error I'm getting for 3 hours straight:
Fatal error: Call to a member function bind_param() on a non-object on line 148
</div>