I'm trying to insert form data into a database, but I keep getting:
Error: INSERT INTO objective_form (name, doa) VALUES (, ) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' )' at line 2
This is the code:
<?php
$name = $_POST["Patient Name"];
$doa = $_POST["Date of Assessment"];
// Create connection
$conn = new mysqli("localhost","username","pw","db");
// Check connection
if ($conn->connect_error) {
die("Connection error.");
}
$sql = "INSERT INTO objective_form (name, doa)
VALUES ($name, $doa)";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
What's the issue here?
EDIT: I've edited the code, done all of your suggestions, and it still isn't working, despite using the prepared statements, and using the suggested code, still displays error message.