I am trying to delete some data from a table in Workbench, but when I press the delete button I get this error;
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 'Name='Stephenie Meyer' and Year_of_birth='1985'' at line 1.
This is the code:
$author=$_POST['AuthorID'];
$name=$_POST['Name'];
$year=$_POST['Year_of_birth'];
$author=htmlspecialchars($author);
$name=htmlspecialchars($name);
$year=htmlspecialchars($year);
if($db_found)
{
$SQL="SELECT*from books WHERE AuthorID='$author' Name='$name' and Year_of_birth='$year'";
$result=mysql_query($SQL) or die(mysql_error());
while($row=mysql_fetch_assoc($result))
{
echo "<tr><td>".$row["AuthorID"]."</td><td>".$row["Name"]."</td><td>".$row["Year_of_birth"]."</td></tr>" ;
}
echo "</table><br>";
$DQL="DELETE from books WHERE AuthorID='$author' , Name='$name' and Year_of_birth='$year'";
if ($db_handle->query($DQL) === TRUE)
{
echo "Record(s) deleted successfully";
}
else
{
echo "Error deleting record: " . $db_handle->error;
}
}
else
{
echo"Record not found";
}
Can you please help?