title: JSON Client Is not receiving Data from The Server for PHP development
body: <p>This is my first question on stackoverflow, so i apologize in advance if its been asked and answered before. I tried searching but could not find an answer, or maybe i don't know the exact terms to use.</p>
  
  <p>I'm current learning PHP and Android and recently got onto the topic of webservices (in both of the languages). I made a basic JSON webservice using php but its not working properly. Below is the code</p>
  
  <p>JSON Server : </p>
  
  <pre><code>&lt;?php
  $hostname="localhost";
  $username="root";
  $pass="";
  $dbname="general db";
  
  $connect=mysql_connect($hostname,$username,$pass);
  mysql_select_db($dbname,$connect) or die("DB not Found");
  
  $query=mysql_query("select * from products");
  
  $jsonobj= array();
  while($result=mysql_fetch_object($query))
  {
      $jsonobj[]=$result; 
  }
  $final=json_encode($jsonobj);
  echo $final;
  ?&gt;
  </code></pre>
  
  <p>Json Client :</p>
  
  <pre><code>&lt;?php
  $jsonobj=file_get_contents('http://localhost/Bhavil/WebServices/JsonServices/JsonEg1_server.php');
  $final=json_decode($jsonobj,true);
  var_dump($final);
  echo json_last_error();
  ?&gt;
  </code></pre>
  
  <p>The output I get when I run the server is :</p>
  
  <pre><code>[
   {"ID":"1","Name":"Sunglasses","Price":"1000"},
   {"ID":"2","Name":"Mobile     Phone","Price":"40000"},
   {"ID":"3","Name":"Mouse","Price":"5000"},
   {"ID":"4","Name":"Pen","Price":"10"}
  ]
  </code></pre>
  
  <p>This is the data stored in the table.</p>
  
  <p>But when I run the client I get null as the output :</p>
  
  <pre><code>D:\Program Files\Wamp Server\www\bhavil\WebServices\JsonServices\JsonEg1_client.php:5:null
  </code></pre>
  
  <p>and Json_last_error() returns '4'. </p>
  
  <p>I dont know what i'm doing wrong, I've checked it a hundred times and tried too many things but nothing works.</p>
  
  <p>Other Details:</p>
  
  <p>OS: Windows 10.</p>
  
  <p>PHP Version : 5.5.12</p>
  
  <p>Apache Version : 2.4.9</p>
  
  <p>Using Wamp Server 2.5 for testing</p>