The problem:
I had a very unsafe way to insert things into my database, so someone on stack here told me how to do it better. Thanks to that person! But there's a problem... The moment I want to insert the data I get this:
Fatal error: Call to a member function bind_param() on a non-object
So I did a var_dump of my $stmt var and it puts out: NULL
Here's the code:
$conn = new mysqli('localhost', 'my_username', 'my_password', 'my_database');
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$nowDate=date("d/m/Y H:i:s");
$stmt = $conn->prepare("INSERT INTO projecten (`user_ref`, `email_user`, `date_created`, `title`, `tweet`, `description`, `category`, `filename`, `invoice`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param('sssssssss', $gebruikerID, $email, $nowDate, $title, $tweet, $description, $category, $nameImage, $customUniqueId);
/* execute prepared statement */
$stmt->execute();
printf("%d Row inserted.\n", $stmt->affected_rows);
/* close statement and connection */
$stmt->close();
$conn->close();
I've been on This page to check out more about the bind_param, but it doesn't work out that good...
Does someone know the problem and how to fix it?