Hi there, i have a problem with this updater script which means that when i click update, change the record, and press submit-it says record changed or something like that, but does not actually do anything! Here is the code, it is supposed to be three files- list_file.php, update.php, update_ac.php, see what you can make of it. Much appreciated!

<?php
$host="localhost"; // Host name 
$username="teachms_fooduse"; // Mysql username 
$password="science0"; // Mysql password 
$db_name="teachms_foods"; // Database name 
$tbl_name="foods"; // 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");

$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4"><strong>List data from table</strong> </td>
</tr>

<tr>
<td align="center"><strong>Food</strong></td>
<td align="center"><strong>Shop</strong></td>
<td align="center"><strong>Price</strong></td>
<td align="center"><strong>Update</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows['Food']; ?></td>
<td><? echo $rows['Shop']; ?></td>
<td><? echo $rows['Price']; ?></td>

// link to update.php and send value of id 
<td align="center"><a href="update.php?id=<? echo $rows['id']; ?>">update</a></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<?php
mysql_close();
?>

--------------|--------------------------
update.php\/
----------------------------------------
<?php
$host="localhost"; // Host name 
$username="teachms_fooduse"; // Mysql username 
$password="science0"; // Mysql password 
$db_name="teachms_foods"; // Database name 
$tbl_name="foods"; // 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");

// get value of id that sent from address bar
$id=$_GET['id'];


// Retrieve data from database 
$sql="SELECT * FROM $tbl_name WHERE id='$id'";
$result=mysql_query($sql);

$rows=mysql_fetch_array($result);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<form name="form1" method="post" action="update_ac.php">
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>&nbsp;</td>
<td colspan="3"><strong>Update data in mysql</strong> </td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td align="center"><strong>Food</strong></td>
<td align="center"><strong>Shop</strong></td>
<td align="center"><strong>Price</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center"><input name="Food" type="text" id="Food" value="<? echo $rows['Food']; ?>"></td>
<td align="center"><input name="Shop" type="text" id="Shop" value="<? echo $rows['Shop']; ?>" size="15"></td>
<td><input name="Price" type="text" id="Price" value="<? echo $rows['Price']; ?>" size="15"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>"></td>
<td align="center"><input type="submit" name="Submit" value="Submit"></td>
<td>&nbsp;</td>
</tr>
</table>
</td>
</form>
</tr>
</table>

<?

// close connection 
mysql_close();

?>
-------------------|-----
update_ac.php \/
-------------------------
<?php
$host="localhost"; // Host name 
$username="teachms_fooduse"; // Mysql username 
$password="science0"; // Mysql password 
$db_name="teachms_foods"; // Database name 
$tbl_name="foods"; // 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");

// update data in mysql database 
$sql="UPDATE $tbl_name SET Food='$Food', Shop='$Shop', Price='$Price' WHERE id='$id'";
$result=mysql_query($sql);

// if successfully updated. 
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='list_file.php'>View result</a>";
}

else {
echo "ERROR";
}

?>
Finish!

For those wondering how i fixed it: in update_ac.php, it has $food.php in the update line, but no specifier. it did not define $food. So i added a post variable. here is the new update_ac.php code:
---------------------------------------
---------------------------------------

<?php
$host="localhost"; // Host name 
$username="teachms_fooduse"; // Mysql username 
$password="science0"; // Mysql password 
$db_name="teachms_foods"; // Database name 
$tbl_name="foods"; // 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");

$Food=$_POST['Food'];
$Shop=$_POST['Shop'];
$Price=$_POST['Price'];
$id=$_POST['id'];

// update data in mysql database 
$sql="UPDATE $tbl_name SET Food='$Food', Shop='$Shop', Price='$Price' WHERE id='$id'";
$result=mysql_query($sql);

// if successfully updated. 
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='list_file.php'>View result</a>";
}

else {
echo "ERROR";
}

?>
This question has already been answered. Start a new discussion instead.