0

I made a little code to update record in database like this:

require_once('includes/config.php');

if ((isset($_POST["DO_update"])) && ($_POST["DO_update"] == "edit_product")) {

	$ProductID = $_POST["txtProductID"];
	$CategoryID = $_POST["txtCategoryID"];
	$ProductName = $_POST["txtProductName"];
	$ProductPrice = $_POST["txtProductPrice"];
	$IsRebate = $_POST["selIsRebate"];
	$RebatePrice = $_POST["txtRebatePrice"];
	$ImageFileName = $_POST["txtImageFileName"];
	$BigImageFileName = $_POST["txtBigImageFileName"];
	$ProductDetails = $_POST["txtProductDetails"];

	$query_update  = "UPDATE ks_products SET `prod_name` = '$ProductName'";
	$query_update .= ", `prod_price` = '$ProductPrice'";
	$query_update .= ", `prod_is_rebate` = '$IsRebate'";
	$query_update .= ", `prod_rebate_price` = '$RebatePrice'";
	$query_update .= ", `prod_image` = '$ImageFileName'";
	$query_update .= ", `prod_big_image` = '$BigImageFileName'";
	$query_update .= ", `prod_details` = '$ProductDetails'";
	$query_update .= ", `cat_id` = '$CategoryID'";
	$query_update .= "WHERE `prod_id` = '$ProductID' LIMIT 1";

	mysql_select_db($database_index, $index);
	mysql_query($query_update, $index) or die(mysql_error());

}

No error found but the record cannot be updated, plz help me!
Only prod_price, prod_is_rebate and prod_rebate_price column is mediumint, others is varchar.

PHP version 5.0.4, MySQL version 4.1

2
Contributors
5
Replies
6
Views
11 Years
Discussion Span
Last Post by N3UR0P0LL
0

Remove the ' ' quote from your script will do

$query_update  = "UPDATE ks_products SET 
	prod_name = '$ProductName',
	prod_price = '$ProductPrice',
	prod_is_rebate = '$IsRebate',
	prod_rebate_price = '$RebatePrice',
	prod_image = '$ImageFileName',
	prod_big_image = '$BigImageFileName',
	prod_details = '$ProductDetails',
	cat_id = '$CategoryID'
  WHERE prod_id = '$ProductID' LIMIT 1";
0

What error message you get?
Make sure you connect to the database properly.
Make sure your database got the variables you use.

You may want to add echo $ProductDetails; after
$ProductDetails = $_POST["txtProductDetails"];
to see if the POST is actually working.

0

What error message you get?
Make sure you connect to the database properly.
Make sure your database got the variables you use.

You may want to add echo $ProductDetails; after
$ProductDetails = $_POST["txtProductDetails"];
to see if the POST is actually working.

Yes, you are right. I found that the $_POST didn't get value from submit form.

Thanks for your advice.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.