Hi all, i am having issues with my php and sql script. I have created a an update form that is populated with the database contents, however, when i edit the fields, the update script fails to update the database. The form looks like;
<form action="update-stock.php" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="text" value="<?php echo $make; ?>" maxlength="10" name="make" size="25" /><br />
<input type="text" value="<?php echo $model; ?>" maxlength="10" name="model" size="25" /><br />
<input type="text" value="<?php echo $price; ?>" maxlength="10" name="price" size="25" /><br />
<input type="text" value="<?php echo $engine; ?>" maxlength="10" name="engine" size="25" /><br />
<input type="text" value="<?php echo $gears; ?>" maxlength="10" name="gears" size="25" /><br />
<input type="text" value="<?php echo $tax; ?>" maxlength="10" name="tax" size="25" /><br />
<input type="text" value="<?php echo $year; ?>" maxlength="10" name="year" size="25" /><br />
<input type="text" value="<?php echo $fuel; ?>" maxlength="10" name="fuel" size="25" /><br />
<input type="text" value="<?php echo $miles; ?>" maxlength="10" name="miles" size="25" /><br />
<input type="text" value="<?php echo $transmission; ?>" maxlength="8" name="transmission" size="25" /><br />
<textarea cols="40" rows="5" name="description"><?php echo $description; ?></textarea><br />
<input type="submit" value="submit" />
</form>
My update-stock looks like;
<?php
if (isset($_POST['submit'])) {
$id=$_REQUEST['id'];
$make=$_REQUEST['make'];
$model=$_REQUEST['model'];
$price=$_REQUEST['price'];
$engine=$_REQUEST['engine'];
$gears=$_REQUEST['gears'];
$tax=$_REQUEST['tax'];
$year=$_REQUEST['year'];
$fuel=$_REQUEST['fuel'];
$miles=$_REQUEST['miles'];
$transmission=$_REQUEST['transmission'];
$description=$_REQUEST['description'];
$query= "UPDATE stock SET make='$make', model='$model', price='$price', engine='$engine', gears='$gears', tax='$tax', year='$year', fuel='$fuel', miles='$miles', transmission='$transmission', description='$description' WHERE id='$id";
mysql_query($query) or die(mysql_error());
mysql_close($db);
echo "<p>Congrats Record Updated</p>";
}
?>
I am certain the issue lies here as i am not getting anything returned.