I have looked at other similar Questions, But cannot seem to find a solution. Any help would be appreciated.
When Run, It displays the state error. I'm trying to update a existing record, When i click submit, the following error occurs.
SQLSTATE[42000]: Syntax error or access violation: 1064 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= , Time= , Date=, Description= , Organiser= , Place= , Other_info= , Organ' at line 1
<?php
$servername = "localhost";
$username = "ilyasm2";
$password = "PASSWORD";
$dbname = "ilyasm2_db";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "UPDATE Event SET Event_category= $event_category, Name= $name, Time= $time, Date=$date, Description= $description, Organiser= $organiser, Place= $place, Other_info= $other_info, Organiser_email= $organiser_email, Your_Name= $your_name";
// Prepare statement
$stmt = $conn->prepare($sql);
// execute the query
$stmt->execute();
// echo a message to say the UPDATE succeeded
echo $stmt->rowCount() . " records UPDATED successfully";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>