Problem with PHP and MySQL, How can I fix this code? It doesn’t work. Please help.?
Problem with PHP and MySQL, How can I fix this code? It doesn’t work. Please help.?
if(isset($_POST['submit'])){
$myCode = $_GET['productCode'];
$barcode = $_POST['barcode'];
$name = $_POST['productName'];
$cat = $_POST['category'];
$sup = $_POST['supplier'];
$price = $_POST['price'];
$mark = $_POST['markup'];
$srp = $_POST['srp'];
$optimum = $_POST['optimumLevel'];
$min = $_POST['minimumLevel'];
$crit = $_POST['criticalLevel'];
$query = “UPDATE tbl_product
SET
productName = ‘$name’,
barcode = ‘$barcode’,
price = ‘$price’,
markup = ‘$mark’,
srp = ‘$srp’,
optimumLevel = ‘$optimum’,
minimumLevel = ‘$min’,
criticalLevel = ‘$crit’,
supplierCode = ‘$sup’,
categoryCode = ‘$cat’
WHERE
productCode = ‘” . $row_rsProduct['productCode'] . “‘”;
$query2 = mysql_query($query);
if($query2) {
header(“location:product.php”);
exit();
}
}
Tags: code, doesn't, HELP, mysql, please, problem, this, work
Under Forum

2 Comments for Problem with PHP and MySQL, How can I fix this code? It doesn’t work. Please help.?
1. Mark B | December 27th, 2010 at 2:41 am
Don’t try to mix GET and POST. Make them all the same and try again.
2. ZmZ | December 27th, 2010 at 2:49 am
1 You can save yourself a HUGE headache by using the following to either POST or GET all variables that are passed in and put them in the PHP variable of the same name:
foreach($_POST as $key=>$val){ $$key = nl2br($val); }
So if you have a form submitted with a field named LastName, the above script will put that field in a PHP variable named $LastName
#2 Make sure your query has proper PHP syntax for string formatting. You may want to output the query before it is executed. This will allow you to figure out if the query syntax is incorrect, or if one of the values is not being passed through.
Can you add
echo $query;
after the query and paste the results here?
Leave a Comment for Problem with PHP and MySQL, How can I fix this code? It doesn’t work. Please help.?
You must be logged in to post a comment.
Trackback this post | Subscribe to the comments via RSS Feed