So I am trying to edit a guestbook on a wedding site. I have a page that shows all of my guests who have registered for the wedding. Next to each row I have an edit and delete button. The delete button works, but the entire edit process does not. When I click edit, I then go to the edit.php page, see below:
In the URL bar it displays the correct id and all of the information pops up in the correct boxes. Here is where it doesn't work. When I click update, it doesn't update on the sql server. Here is the code for the edit_process.php :
$query = 'SELECT * FROM $tbl_name WHERE id = $id';
mysql_query("UPDATE guests SET guest_1='$guest_1',guest_2='$guest_2',guest_3='$guest_3'.guest_4='$guest_4',guest_5='$guest_5',attending='$attending',vegetarian='$vegetarian',total_guests='$total_guests',email='email' WHERE id=$id");
echo mysql_error();
?>
Any ideas of why it isn't working. This is the last piece of the puzzle for this site, so any help will be appreciated.
$query = 'SELECT * FROM $tbl_name WHERE id = $id';
mysql_query("UPDATE guests SET guest_1='$guest_1',guest_2='$guest_2',guest_3='$guest_3',guest_4='$guest_4',guest_5='$guest_5',attending='$attending',vegetarian='$vegetarian',total_guests='$total_guests',email='email' WHERE id=$id"); echo mysql_error();
header("Location: rsvp_view.php"); ?>
But now I get this error when the page processes: "You 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
Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/a/r/markandmichell/html/manager/edit_process.php:27) in /home/content/m/a/r/markandmichell/html/manager/edit_process.php on line 29"
When I put that at the top of the edit_process.php file, nothing happens. The page just goes white. Now something interesting I discovered. When I am on the rsvp page and click edit, the id of the row that I want to edit appears in the url "manager/edit.php?id=7" but when I make changes and click update, this is what appears in the url "manager/edit_process.php". The ID information all but disappears when it is trying to update the row.
I am not sure if you know of an easier way of accomplishing this, as you have seen my code. I am open to suggestions.
When I put that at the top of the edit_process.php file, nothing happens.
Ahh. Yeah, that's the point. It means your ID isn't being passed through in the hidden form variable-- if it were, you'd have seen it on that page. Most likely it's not being sent to edit_process.php at all.
EDIT: And yes, that's the problem. This line in your HTML:
Bookmarks