[Please HELP] Cannot Update Record

Reply

Join Date: Jun 2005
Posts: 4
Reputation: N3UR0P0LL is an unknown quantity at this point 
Solved Threads: 0
N3UR0P0LL N3UR0P0LL is offline Offline
Newbie Poster

[Please HELP] Cannot Update Record

 
0
  #1
Jun 14th, 2005
I made a little code to update record in database like this:
[PHP]
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());

}
[/PHP]
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: [Please HELP] Cannot Update Record

 
0
  #2
Jun 14th, 2005
Remove the ' ' quote from your script will do
[PHP]$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";[/PHP]
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: N3UR0P0LL is an unknown quantity at this point 
Solved Threads: 0
N3UR0P0LL N3UR0P0LL is offline Offline
Newbie Poster

Re: [Please HELP] Cannot Update Record

 
0
  #3
Jun 14th, 2005
Thanks for your help but it didn't work :cry:
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: N3UR0P0LL is an unknown quantity at this point 
Solved Threads: 0
N3UR0P0LL N3UR0P0LL is offline Offline
Newbie Poster

Re: [Please HELP] Cannot Update Record

 
0
  #4
Jun 14th, 2005
I found the bug and fixed it. Thanks for your help :cheesy:
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: [Please HELP] Cannot Update Record

 
0
  #5
Jun 14th, 2005
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.
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 4
Reputation: N3UR0P0LL is an unknown quantity at this point 
Solved Threads: 0
N3UR0P0LL N3UR0P0LL is offline Offline
Newbie Poster

Re: [Please HELP] Cannot Update Record

 
0
  #6
Jun 14th, 2005
Originally Posted by zippee
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['txtProductID'] didn't get value from submit form.

Thanks for your advice.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC