I'm using an html form to update mysql database using php. and it keeps giving 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 'WHERE id = '1'' at line 1"
here is y php code:
<?php
$host="localhost"; // Host name
$username="name"; // Mysql username
$password="pass"; // Mysql password
$db_name="dbname"; // Database name
$tbl_name="tblname"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$id = '1';
$name = $_POST['name'];
$info = $_POST['minfo'];
$poster = $_POST['poster'];
$mtrailer = $_POST['mtrailer'];
// update data in mysql database
$sql = "UPDATE movies SET name='$name', info='$info', poster='$poster', mtrailer='$mtrailer', WHERE id = '$id'";
$result = mysql_query($sql) or die(mysql_error());;
?>
and this is the html form that I'm using:
<FORM action="update.php" method="post">
<INPUT type="text" name="name" value="<?php echo $name; ?>" id="name" placeholder="Name" required=""><BR>
<INPUT type="text" name="minfo" value="<?php echo $info; ?>" id="minfo" placeholder="Description" required=""><BR>
<INPUT type="text" name="poster" value="<?php echo $poster; ?>" id="poster" placeholder="Poster URL" required=""><BR>
<INPUT type="text" name="mtrailer" value="<?php echo $trailer; ?>" id="mtrailer" placeholder="Trailer URL" required=""><BR>
<INPUT type="submit" value="update">
</FORM>