I am trying to code an update sql command which can be seen in the code below, however, i am getting the following error: -
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/qchqsdju/public_html/project/lines/update_line.php on line 40.
The code is: -
<?
// Connect database.
include("../db/db_connect.php");
// ***** This part will process when you Click on "Submit" button *****
if($_POST['Submit']){
// Get parameters from form.
$barcode=$_POST['barcode'];
$product=$_POST['product'];
$department=$_POST['department'];
$mpl=$_POST['mpl'];
$price=$_POST['price'];
// Do update statement.
mysql_query("update lines set barcode='$barcode', product='$product', department='$department', mpl='$mpl', price='$price' where barcode='$barcode'");
// Re-direct this page to select.php.
header("location:view_lines.php");
exit;
}
// ************* End update part *************
// *** Select data to show on text fields in form. ***
// Get id parameter (GET method) from select.php
$id=$_GET['barcode'];
// Get records in all columns from table where column id equal in $id and put it in $result.
$result=mysql_query("select * from lines where id='$id'");
// Split records in $result by table rows and put them in $row.
$row=mysql_fetch_assoc($result);
// Close database connection.
mysql_close();
?>
Does anyone know why I am getting this error?
Any help will be appreciated.