在此Web服务中,用户数据已更新并返回JSON响应。每当我在浏览器中运行查询时,它都能完美运行。但是当我从Android应用程序访问webservice时,响应为空。我的代码是,
UpdateData.php(web服务)
<?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;
}
}
?>
任何帮助将不胜感激。