I am getting this error when trying to insert data into my database from my website:
Error: INSERT INTO newtask (new_category, new_department, new_required,
new_name, new_address, new_contact, new_email, new_logged, new_description)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
You have an error in your SQL syntax; check the manual that corresponds to
your
MySQL server version for the right syntax to use near '?, ?, ?, ?, ?, ?, ?,
?,
?)' at line 1
Here is my code:
<?php
$servername = 'localhost';
$username = 'root';
$password = '';
$dbname = 'tasks_db';
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO newtask (new_category, new_department, new_required,
new_name, new_address, new_contact, new_email, new_logged, new_description)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Not sure what i am doing wrong here?