In this webservice, user data is updated and return JSON response. Whenever I run query in browser it works perfectly. But when I access webservice from android app, response is null. My code is,
UpdateData.php(Webservice)
<?php
require_once 'DB_Functions.php';
$db = new DB_Functions();
// receiving the post params
$name = "Amey";
$address = "PPR2";
$email = "2653@abc.com";
$contact = "123456";
$vid = "zh0000000";
$user=$db->updateUser($name, $address, $email, $contact, $vid);
echo json_encode($user);
?>
DBFunction.php
<?php
class DB_Functions {
private $conn;
// constructor
function __construct() {
require_once 'DBConnect.php';
// connecting to database
$db = new DBConnect();
$this->conn = $db->connect();
}
// destructor
function __destruct() {
}
public function updateUser($name, $address, $email, $contact, $voter_id) {
$sql = "UPDATE user SET user_name=?, user_address=?, user_email_id=?, user_mob_no=? WHERE voter_id=?";
$stmt =$this->conn->prepare($sql);
$stmt->bind_param('sssss', $name, $address, $email, $contact, $voter_id);
$stmt->execute();
if ($stmt->errno) {
$variable= "FAILURE!!! " . $stmt->error;
}
$variable= "Updated";
$stmt->close();
return $variable;
}
}
?>
Any help will be appreciated.