Editting Record problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpnew
Forum Newbie
Posts: 18
Joined: Tue Oct 12, 2004 7:40 am

Editting Record problem

Post by phpnew »

Sami | Help us, help you. Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Hello all

I am developing a site for a estate agent and am not able to edit the record from mysql database.

When I take my curser on to the edit link it shows the record id.
http://localhost/admin/edit_property.php?id=9 (ie) it seems to identify the id but does not show data in the record the record. 

here is what is written in the delete_property.php

Code: Select all

<?php require("stuff.php");
require("validate_user.php");

$property_edited = false;

if (isset($_POST['submit'])) {
$edit_property = $_POST['edit_property'];
$property_type = $_POST['property_type'];
$contract = $_POST['contract'];
$bedrooms = $_POST['bedrooms'];
$property_details = $_POST['property_details'];
$property_value = $_POST['property_value'];
$area = $_POST['area'];
$id = $_POST['id'];
if (isset($edit_property) && ($edit_property == "validated")) 
	$property_details = trim($property_details);
	$property_value = trim($property_value);
	if (is_numeric($property_value)) {
		$db_connection = db_connect();
		$query = "UPDATE houses SET property_type='$property_type', contract='$contract', bedrooms='$bedrooms', details='$property_details', value='$property_value', area='$area' WHERE id='$id'";
		db_query($query, $db_connection);

      if (is_uploaded_file($property_image)) {
      	// there was a file uploaded with the product
		   $image_properties = getimagesize($property_image);
		   if ($image_properties[2] == 2) {
		   	// the file was a valid image
		      $image_width = $image_properties[0];
		      $image_height = $image_properties[1];
		      $new_width = 175;
		      if ($image_width > $new_width) {
		        	// the image is too big, so we must resize it
		        	$ratio = $new_width / $image_width;
		        	$new_height = $image_height*$ratio;

            	$image = ImageCreateFromJPEG($property_image);
	           	$new_image = ImageCreateTrueColor($new_width, $new_height);
            	ImageCopyResized($new_image,$image,0,0,0,0,$new_width,$new_height,$image_width,$image_height);
            	ImageJPEG($new_image, $property_image);
            }
            $image_name = "C:\Program Files\Apache Group\Apache\htdocs\pictures\property_".$id.".jpg";
            copy($property_image, $image_name);
         }
      }

		db_disconnect($db_connection);
		$property_edited = true;
	}
}

?>
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

echo out the $query before you execute to ensure that the format is correct
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Code: Select all

$id = $_POST['id'];
Your getting your id from POST instead of GET.
phpnew
Forum Newbie
Posts: 18
Joined: Tue Oct 12, 2004 7:40 am

Post by phpnew »

Thank you all for your response it is solved

Thank you
Post Reply