I am trying to do a database update with php and I am getting a syntax error. I have looked and looked and cannot find what the issue could be…
Error
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
UPDATE `new_equip`
EditPost.php
<?php
ob_start();
// contact to database
$host = "localhost";
$username = "admin";
$password = "pass";
$database="database";
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$insert_data = mysql_real_escape_string($input_data);
$id= intval($_POST['EditID']);
//echo $id;exit();
$itemname= strip_tags($_POST['itemname']);
$model= strip_tags($_POST['model']);
$serial= strip_tags($_POST['serial']);
$year= strip_tags($_POST['year']);
$desc= $_POST['desc'];
$dimension= strip_tags($_POST['dimension']);
$location= strip_tags($_POST['location']);
$price= intval($_POST['price']);
$purchase= strip_tags($_POST['purchase']);
$year= intval($_POST['year']);
$addedby= intval($_POST['addedby']);
$notes= strip_tags($_POST['notes']);
$ran= strip_tags($_POST['ran']);
$electrical= strip_tags($_POST['electrical']);
$owner= strip_tags($_POST['owner']);
$manufactuer= strip_tags($_POST['manufactuer']);
$condition= strip_tags($_POST['condition']);
$EditID= intval($_POST['EditID']);
$category= strip_tags($_POST['category']);
$redirect = "inventory.php?Msg=Update";
$featured = strip_tags($_POST['featured']);
$query = "UPDATE `new_equip` SET `itemname`='$itemname',`manufactuer`='$manufactuer',`model`='$model',`serial`='$serial',`year`='$year',`category`='$category',`electrical`='$electrical',`desc`='$desc',`dimension`='$dimension',`location`='$location',`price`='$price',`condition`='$condition',`ran`='$ran',`addedby`='$addedby',`purchase`='$purchase',`notes`='$notes',`owner`='$owner',`featured`='on'WHERE `id`='$id' LIMIT 1";
mysql_query($query) or die(mysql_error() . "<br />" . $query);
// Redirect
header("Location: " . $redirect);
ob_flush();
?>
I know I should switch to mysqli and I tried but I BOMBED bad. I couldnt get it to work.