I have a problem about getting JSON value from php file.
How can I fix it?
<?php
//If the values are not blank
//Connecting to our database by calling dbConnect script
include('connection.php');
$id =$_POST["uyeId"];
Class UyeBilgiler{
public $uyeAd = "";
public $uyeYas = "";
public $uyeOkul = "";
public $uyeResim = "";
public $uyeEmail = "";
}
$uyeBilgiler = new UyeBilgiler();
$informationSql = "SELECT * FROM bilgiler WHERE id = '$id' ";
$list = mysqli_query($conn,$informationSql);
while($result = mysqli_fetch_assoc($list)){
$uyeBilgiler->uyeAd = $result["uyeAd"];
$uyeBilgiler->uyeYas = $result["uyeYas"];
$uyeBilgiler->uyeOkul = $result["uyeOkul"];
$uyeBilgiler->uyeResim = $result["uyeResim"];
$uyeBilgiler->uyeEmail = $result["uyeEmail"];
echo json_encode($uyeBilgiler,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
}
?>
When I assign a value to $id variable as 1, the output of json format is displayed below.
{ "uyeAd": "Ali yılmaz", "uyeYas": "29", "uyeOkul": "Ali Myo", "uyeResim": "bir.jpg", "uyeEmail": "ali@gmail.com" }
There is a gap after first fancy braces and before last fancy braces.
For android part,
@GET("/getInformationByUyeId.php")
Call<UyeBilgiler> bilgiGetir(@Query("uyeId") String id);
When I define a $id manually ($id = "1") without using $_POST["uyeId"], I get a json file without any error. But using $_POST["uyeId"] throw an error as shown below.
Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $