-1

This is my code and I can't figure out how to update the product_info:

include_once "dbconnect.php";
session_start();

$p_id = $_SESSION['rbtn'];
$p_name=securethis( $_POST['p_name']);
$p_unit=securethis( $_POST['p_unit']);
$p_price=securethis( $_POST['p_price']);
$p_details=securethis($_POST['p_details']);

$query= "UPDATE product_info SET p_name=$p_name,p_unit=$p_unit,p_price=$p_price,p_details=$p_details,p_directory=hi WHERE p_id=$p_id";
mysql_query($query) or die(mysql_error()) ;

$_SESSION['rbtn'] = "";
header("Location: admin.php");
shrestha_aj
  • 336
  • 3
  • 12

2 Answers2

3

Your used query should be in valid format to execute by MySQL . May be there are some columns in product_info table are VARCHAR type like as p_name . So use single quote (') to create a valid query . You can also check it by echoing your query and execute this on MYSQL prompt . It will tell the exact problem.

echo $query= "UPDATE product_info SET p_name=$p_name,p_unit=$p_unit,p_price=$p_price,p_details=$p_details,p_directory=hi WHERE p_id=$p_id";

and execute the the printed query directly to the MYSQL shell .

Deepak Dixit
  • 1,510
  • 15
  • 24
1

Write the query like this-

$query= "UPDATE product_info SET p_name='$p_name',p_unit='$p_unit',p_price='$p_price',p_details='$p_details',p_diretory='hi' WHERE p_id='$p_id'";
Sajeeb Ahamed
  • 6,070
  • 2
  • 21
  • 30