I am trying to update data in a database but it won't work. I don't get any errors but it doesn't work. I can delete the data and insert it but not delete it. Here is my coding.
<html>
<head>
<title>Edit A Puppy</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$conn = mysql_connect(HOST, USER, PASS)
or die
('Error connecting to mysql');
mysql_select_db(brw123_puppies);
if(isset($_GET['id']))
{
$query = "SELECT id, name, price, description ".
"FROM pups ".
"WHERE id = '{$_GET['id']}'";
$result = mysql_query($query) or die('Error : ' . mysql_error());
list($id, $name, $price, $description) = mysql_fetch_array($result,
MYSQL_NUM);
$description = htmlspecialchars($description);
}
else if(isset($_POST['save']))
{
$id = $_POST['id'];
$name = $_POST['name'];
$price = $_POST['price'];
$description = $_POST['description'];
// update the article in the database
$query = "UPDATE pups ".
"SET name = '$name', price = '$price', description = '$description' ".
"WHERE id = '$id'";
mysql_query($query) or die('Error : ' . mysql_error());
echo "$name has been updated";
}
mysql_close($conn);
?>
<form method="post">
<input type="hidden" name="id" value="<?=$id;?>">
<table border="1">
<tr>
<td width="100">Name:</td>
<td><input name="name" type="text"id="name" value="<?=$name;?>"></td>
</tr>
<tr>
<td width="100">Price:</td>
<td>$<input name="price" type="text" id="price" value="<?=$price;?>"></td>
</tr>
<tr>
<td width="100">Content</td>
<td><textarea name="description" cols="30" rows="6" id="description"><?=$description;?></textarea></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><input name="update" type="submit" id="update" value="Update <?=$name;?>"></td>
</tr>
</table>
<p align="center"><a href="puppyadmin.php">Manage Your Dogs</a></p>
</form>
</body>
</html>
Thanks in advance.