-1

I m trying to get the existing "usercouponinhand" value from "userpaytoget" table and add it to received 'id' value as from "GET" tag. Then update it to the same "userpaytoget" table "usercouponinhand" column.

But unfortunately i see this "Unexpected =" error on the line result = $conn->query($sql);

The code follows:

<?php include('usercoupondelete.php'); ?>
<?php
$servername  = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "";

$mobile = $_SESSION['mobile'];
$date = date('M-d,Y H:i:s');
$date2 = date('M-d,Y');

$conn = new mysqli ($servername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM userpaytoget WHERE mobile = '$mobile' ";
result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {

$usercouponinhand = $row["usercouponinhand"];
$couponvalue = $_GET["id"];
$totalvalue = $couponvalue + $usercouponinhand ;

$sql2 = "UPDATE userpaytoget SET usercouponinhand = '$totalvalue', date = '$date', date2 = '$date2'
WHERE mobile = '$mobile'";

if ($conn->query($sql2) === TRUE) {
echo  '<a href="usercoupondelete"></a>';
}
else {
echo "ERROR" . $sql2 . "<br>" . $conn->error;
}

}
 } else {
echo "None";
} 
$conn->close();
?>

Any Help is greatly appreciated..

1 Answers1

0

You are missing a $

It should be $result = $conn->query($sql);

dobaniashish
  • 66
  • 1
  • 5