| | |
[Please HELP] Cannot Update Record
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 4
Reputation:
Solved Threads: 0
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
[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
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]
[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.
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.
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.
•
•
Join Date: Jun 2005
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
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.
Thanks for your advice.
![]() |
Similar Threads
- How to Update a record in a database (PHP)
- vb6 update record in the database (Visual Basic 4 / 5 / 6)
- Select + update not working together (ASP)
- Problem with update data to database (JSP)
- retreive and update from check boxes (ColdFusion)
- Record Locking in VB through DAO via MS Access (Visual Basic 4 / 5 / 6)
Other Threads in the PHP Forum
- Previous Thread: help with php and javascript
- Next Thread: Mysql_num_rows($result)
| Thread Tools | Search this Thread |
ajax apache api array back basic beginner binary broken cakephp checkbox class cms code computing cron curl database date delete display dynamic echo email error external file files filter folder form forms function functions gc_maxlifetime google host href htaccess html iframe image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm multiple mysql navigation oop parsing paypal pdf php problem query question radio random recursion regex remote script search server sessions sms snippet soap source space sql syntax system table thesishelp trouble tutorial update upload url validation validator variable video web xml youtube





