title: SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse
body: <p>I created an application with ionic with the help of this tutorial: <a href="http://masteringionic.com/blog/2016-12-15-using-php-and-mysql-with-ionic/" rel="nofollow noreferrer">http://masteringionic.com/blog/2016-12-15-using-php-and-mysql-with-ionic/</a> a school programm</p>
  
  <p>But when i want to select all my client, i get this error :</p>
  
  <blockquote>
    <p>SyntaxError: Unexpected token &lt; in JSON at position 0 at JSON.parse () at XMLHttp…, text</p>
  </blockquote>
  
  <p>My PHP script : </p>
  
  <pre><code>    &lt;?php
  
     // Define database connection parameters
     $hn      = 'localhost';
     $un      = 'root';
     $pwd     = '';
     $db      = 'equida';
     $cs      = 'utf8';
  
  
     // Set up the PDO parameters
     $dsn     = "mysql:host=" . $hn . ";port=3306;dbname=" . $db . ";charset=" . $cs;
     $opt     = array(
                          PDO::ATTR_ERRMODE            =&gt; PDO::ERRMODE_EXCEPTION,
                          PDO::ATTR_DEFAULT_FETCH_MODE =&gt; PDO::FETCH_OBJ,
                          PDO::ATTR_EMULATE_PREPARES   =&gt; false,
                         );
     // Create a PDO instance (connect to the database)
     $pdo     = new PDO($dsn, $un, $pwd, $opt);
     $data    = array();
  
  
     // Attempt to query database table and retrieve data
     try {
        $stmt     = $pdo-&gt;query('SELECT * FROM client');
        while($row  = $stmt-&gt;fetch(PDO::FETCH_OBJ))
        {
           // Assign each row of data to associative array
           $data[] = $row;
        }
  
        // Return data as JSON
        echo json_encode($data);
     }
     catch(PDOException $e)
     {
        echo $e-&gt;getMessage();
     }
  
  
  ?&gt;
  </code></pre>
  
  <p>My javascript :</p>
  
  <pre><code>import { Component } from '@angular/core';
  import { NavController } from 'ionic-angular';
  import { HttpClient } from '@angular/common/http';
  
  @Component({
    selector: 'page-lst-client',
    templateUrl: 'lst-client.html'
  })
  export class LstClientPage {
     /**
      * @name items
      * @type {Array}
      * @public
      * @description     Used to store returned PHP data
      */
     public items : Array&lt;any&gt; = [];
  
     constructor(public navCtrl: NavController,
                 public http   : HttpClient)
     {
  
     }
  
  
     /*
      * Triggered when template view is about to be entered
      * Returns and parses the PHP data through the load() method
      *
      * @public
      * @method ionViewWillEnter
      * @return {None}
      */
     ionViewWillEnter() : void
     {
        this.load();
     }
  
  
     /*
      * Retrieve the JSON encoded data from the remote server
      * Using Angular's Http class and an Observable - then
      * assign this to the items array for rendering to the HTML template
      *
      * @public
      * @method load
      * @return {None}
      */
     load() : void
     {
        this.http
        .get('wequida/retrieve-client.php')
        .subscribe((data : any) =&gt;
        {
           console.dir(data);
           this.items = data;
        },
        (error : any) =&gt;
        {
           console.dir(error);
        });
     }
  
  
     /*
      * Allow navigation to the AddTechnologyPage for creating a new entry
      *
      * @public
      * @method addEntry
      * @return {None}
      */
     addEntry() : void
     {
        this.navCtrl.push('AddClientPage');
     }
  
  
     /*
      * Allow navigation to the AddTechnologyPage for amending an existing entry
      * (We supply the actual record to be amended, as this method's parameter,
      * to the AddTechnologyPage
      *
      * @public
      * @method viewEntry
      * @param param      {any}           Navigation data to send to the next page
      * @return {None}
      */
     viewEntry(param : any) : void
     {
        this.navCtrl.push('AddClientPage', param);
     }
  }
  </code></pre>