HELP! having problems updating mysql database with php

hi guys i have all the other php and database setup for my site, the section i am having problems with is i am trying to update a existing entry into my database. i want it to over write the old entry.

i have the edit page setup where it pulls the data from the database, i can edit it all fine but when i submit it, it writes it as a new entry not replaceing the old one. it gives it a new id ( i think its the id for the entry where i am having problems)

here is the code i have on my page (i have removed the connect to database section :slight_smile: )

any help with this would rock as its really starting to bug me now lol

thanks in advance for your time helping me :slight_smile:

<?php // updates the hotel in the Database if (isset($_POST['hotel_name'])) { $pid = mysql_real_escape_string($_POST['id']); $product_line = mysql_real_escape_string($_POST['product_line']); $city = mysql_real_escape_string($_POST['city']); $hotel_name = mysql_real_escape_string($_POST['hotel_name']); $room_type1 = mysql_real_escape_string($_POST['room_type1']); $price1 = mysql_real_escape_string($_POST['price1']); $room_type2 = mysql_real_escape_string($_POST['room_type2']); $price2 = mysql_real_escape_string($_POST['price2']); $room_type3 = mysql_real_escape_string($_POST['room_type3']); $price3 = mysql_real_escape_string($_POST['price3']); $room_type4 = mysql_real_escape_string($_POST['room_type4']); $price4 = mysql_real_escape_string($_POST['price4']); $room_type5 = mysql_real_escape_string($_POST['room_type5']); $price5 = mysql_real_escape_string($_POST['price5']); $room_type6 = mysql_real_escape_string($_POST['room_type6']); $price6 = mysql_real_escape_string($_POST['price6']); $room_type7 = mysql_real_escape_string($_POST['room_type7']); $price7 = mysql_real_escape_string($_POST['price7']); $room_type8 = mysql_real_escape_string($_POST['room_type8']); $price8 = mysql_real_escape_string($_POST['price8']); $room_type9 = mysql_real_escape_string($_POST['room_type9']); $price9 = mysql_real_escape_string($_POST['price9']); $room_type10 = mysql_real_escape_string($_POST['room_type10']); $price10 = mysql_real_escape_string($_POST['price10']); $specials = mysql_real_escape_string($_POST['specials']); $small_details = mysql_real_escape_string($_POST['small_details']); $main_details = mysql_real_escape_string($_POST['main_details']); $facilities = mysql_real_escape_string($_POST['facilities']); $google_map = mysql_real_escape_string($_POST['google_map']); // See if that product name is an identical match to another product in the system $sql = mysql_query("UPDATE products SET id='$pid', product_line='$product_line', city='$city', hotel_name='$hotel_name', room_type1='$room_type1', price1='$price1', room_type2='$room_type2', price2='$price2', room_type3='$room_type3', price3='$price3', room_type4='$room_type4', price4='$price4', room_type5='$room_type5', price5='$price5', room_type6='$room_type6', price6='$price6', room_type7='$room_type7', price7='$price7', room_type8='$room_type8', price8='$price8', room_type9='$room_type9', price9='$price9', room_type10='$room_type10', price10='$price10', specials='$specials', small_details='$small_details', main_details='$main_details', facilities='$facilities', google_map='$google_map' WHERE id='$pid'"); if ($_FILES['fileField']['tmp_name'] !="") { // Place image in the folder flash $newname1 = "$pid.swf"; move_uploaded_file($_FILES['fileField']['tmp_name'], "../hotel_flash/$newname1"); // Place image in the folder small image $newname2 = "$pid.jpg"; move_uploaded_file($_FILES['fileField']['tmp_name'], "../hotel_images/$newname2"); } header("location: index.php"); exit(); } ?> <?php // pull the info into the form so i can change it if (isset($_GET['pid'])) { $targetID = $_GET['pid']; $sql = mysql_query("SELECT * FROM products WHERE id='$targetID' LIMIT 1"); $productCount = mysql_num_rows($sql); // counte the product out put ammount if ($productCount > 0) { while($row = mysql_fetch_array($sql)){ $pid = $row["id"]; $product_line = $row["product_line"]; $city = $row["city"]; $hotel_name = $row["hotel_name"]; $room_type1 = $row["room_type1"]; $price1 = $row["price1"]; $room_type2 = $row["room_type2"]; $price2 = $row["price2"]; $room_type3 = $row["room_type3"]; $price3 = $row["price3"]; $room_type4 = $row["room_type4"]; $price4 = $row["price4"]; $room_type5 = $row["room_type5"]; $price5 = $row["price5"]; $room_type6 = $row["room_type6"]; $price6 = $row["price6"]; $room_type7 = $row["room_type7"]; $price7 = $row["price7"]; $room_type8 = $row["room_type8"]; $price8 = $row["price8"]; $room_type9 = $row["room_type9"]; $price9 = $row["price9"]; $room_type10 = $row["room_type10"]; $price10 = $row["price10"]; $specials = $row["specials"]; $small_details = $row["small_details"]; $main_details = $row["main_details"]; $facilities = $row["facilities"]; $google_map = $row["google_map"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); } } else { echo "hotel not in Database sorry."; exit(); } } ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service