Hi, Im getting this error
SyntaxError: Unexpected token c in JSON at position 0
at Object.parse (native)
at Response.Body.json (http://localhost:8100/build/main.js:55587:25)
about. ts
export class AboutPage {
items : any;
tabBarElement: any;
constructor(public navCtrl: NavController, public http : Http) {
}
ionViewWillEnter() {
this.load();
document.querySelector('.tabbar.show-tabbar')['style'].display = 'none';
}
ionViewWillLeave() {
document.querySelector('.tabbar.show-tabbar')['style'].display = 'flex';
}
load()
{
this.http.request(‘http://myweb.com/view.php’)
.map(res => res.json())
.subscribe(data =>
{
console.log(data);
this.items = data;
}, (err) => {
console.log(err);
});
}Preformatted text
**view.php**
<?php
header(“Access-Control-Allow-Origin: *”);
header(“Content-Type: charset=UTF-8”);
$data = array();
$pdo = new PDO(‘pgsql:dbname=dbname;user=userdb;password=passdb;host=localhost;port=5432’);
if($pdo) {
echo ‘connected’;
} else {
echo ‘there has been an error connecting’;
}
try {
$sql = “SELECT id_profile, deskripsi FROM public.profile where id_profile=‘1’”;
$select = $pdo->prepare($sql);
$select->execute();
$data = $select->fetch( PDO::FETCH_ASSOC );
echo json_encode($data);
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>