I am trying to update a column of my MySql database which is present in server. I am not getting what mistake am I doing in my query, column is not getting updated. Can any one please show some light on my mistake. I have tried doing this all possible ways, but I am not able to succeed.
I have tried all the following queries:
$sql = "UPDATE AndroidTable SET HasLike ='".$obtainedCount."' WHERE Subject =' " .$obtainedSubject. "'";
$sql = "UPDATE AndroidTable SET HasLike ='.$obtainedCount.' WHERE Subject =' " .$obtainedSubject. "'";
$sql = "UPDATE AndroidTable SET HasLike ='$obtainedCount' WHERE Subject =' " .$obtainedSubject. "'";
In all the above queries I get the response as 1, but my column does not get updated with that value.
Below is my php script:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "iFocusBlogs";
$obtainedSubject = urldecode($_POST['enteredSubject']);
$obtainedCount = urldecode($_POST['enteredCount']);
//print " ==== POST DATA =====
//userName : $userName
//Password : $password
//Status : $status;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE AndroidTable SET HasLike ='.$obtainedCount.' WHERE Subject =' " .$obtainedSubject. "'";
//$obtainedCount
$result=mysqli_query($conn,$sql);
if ($conn->query($sql) === TRUE) {
echo $result ;
} else {
echo "Error: " . $sql . "<br>" . $conn->error();
}
mysqli_commit($conn);
$conn->close();
?>
I am passing the values properly, I have tried printing those values also. All suggestions are welcome. Thanks in advance.