title: JSON giving null result
body: <p>I'm trying to fetch data from my database which located on my web server.</p>
  
  <p>I've uploaded my PHP file get_data.php on to the web server.</p>
  
  <pre><code>    &lt;?php
  define('HOST','localhost.000webhostapp.com');
  define('USER','id1206871_myuser');
  define('PASS','******');
  define('DB','id1206871_mydb'); 
    $con = mysqli_connect(HOST,USER,PASS,DB);
  
    $sql = "select * from person";
  
    $res = mysqli_query($con,$sql);
   while($row = mysqli_fetch_array($res)){
      array_push($result,
      array('id'=&gt;$row[0],
      'name'=&gt;$row[1],
      'address'=&gt;$row[2]
    ));
  }
  $json_errors = array(
      JSON_ERROR_NONE =&gt; 'No error has occurred',
      JSON_ERROR_DEPTH =&gt; 'The maximum stack depth has been exceeded',
      JSON_ERROR_CTRL_CHAR =&gt; 'Control character error, possibly incorrectly encoded',
      JSON_ERROR_SYNTAX =&gt; 'Syntax error',
  );
  
  echo json_encode(array("result"=&gt;$result));
  
  echo 'Last error : ', $json_errors[json_last_error()], PHP_EOL, PHP_EOL;
  mysqli_close($con);
  
  ?&gt;
  </code></pre>
  
  <p>When I try this URL <a href="https://mrpcml.000webhostapp.com/get_data.php" rel="nofollow noreferrer">https://mrpcml.000webhostapp.com/get_data.php</a>
  I get</p>
  
  <blockquote>
    <p>{"result":null}Last error : No error has occurred </p>
  </blockquote>
  
  <p>I've also tried to validate JSON.</p>
  
  <blockquote>
    <p>Error: Parse error on line 1: mrpcml.comli.com / g ^ Expecting
    'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'</p>
  </blockquote>
  
  <p>Why am I getting this <em>null</em>? Where is the problem?
  I'm not sure about my db host.</p>