Database help for a newbie
Posted: Sat Mar 22, 2003 4:53 am
I am writing an administration page for a guestbook. What the admin page does is lets the administrator view the messages that are not authorised, then I want it to be able to change the value of authorised from No to Yes. The cdoe I have for doing that is below. My problem is that when i press add to database, instead of changing the value of authorised, an new record is created (with all the same data) except the id has been incrimented, and authorised is set to Yes. The origional record remains. Could somebody please explain what I am doing wrong - I don't want a new record to be created, I just want the origional record to be updated.
Thanks
Thanks
Code: Select all
<?php
if ($id) {
$sql = "UPDATE `guestbook` SET name='$name',location='$location',email='$email',check='$check',homepage='$homepage',comment='$comment',ip='$ip',date_time='$date_time',authorised='Yes' WHERE `id`='$id'";
print $sql;
}
// run SQL against the DB
$result = mysql_query($sql);
?>