title: Getting error while parsing json data from server
body: <p>I want to search something in the database and I send the word to be searched by POST method to the server and I checked the POST is working fine but when I want to get the data that are related to that searched work it produces this error :</p>
  
  <pre><code> error in AdsParser inparse () -&gt;org.json.JSONException: End of input at character 1 of
  </code></pre>
  
  <p>I checked before and my parser class doesn't have any problem because without the search query inside my below PHP code it gets the json data perfectly,
  here is my PHP code :</p>
  
  <pre><code>&lt;?php
  
  require_once("include.php");
  
  $tbl_name = "ads";
  $order_by = "id";
  
  if(isset($_POST['search_key']))
  {
  
      $key = $_POST['search_key'];
  
      $connect = @mysqli_connect( $hostname , $username , $password , $database );
      if( $connect )
      {
          @mysqli_query( $connect , "SET CHARACTER SET utf8;" );
  
          $my_query = "SELECT * FROM ".$tbl_name.
                          " WHERE title LIKE '%".$key.
                          "%' OR intro LIKE '%".$key.
                          "%' ORDER BY ".$order_by;
  
          $result = @mysqli_query( $connect , $my_query );
          if( $result )
          {
              $response['ads'] = array();
              $response['success'] = 1;
  
              while( $row = @mysqli_fetch_array( $result ) )
              {
                  $ads = array();
  
  
                  $ads['id']  = $row['id'];
                  $ads['title']   = $row['title'];
                  $ads['cost']    = $row['cost']; 
                  $ads['costunit']= $row['costunit']; 
                  $ads['intro']   = $row['intro'];
                          $ads['image']   = $sitename . $row['image'];
                  $ads['seller']  = $row['seller'];
                  $ads['phone']   = $row['phone'];        
                  $ads['date']    = ago($row['date']);
  
  
                  $q = "SELECT name FROM cat WHERE id='".$row['cat_id']."'";
                  $temp1 = @mysqli_query($connect , $q);
                  $temp2 = @mysqli_fetch_row($temp1);
                  $cat = $temp2[0];
  
                  $q1 = "SELECT name FROM cities WHERE id='".$row['city_id']."'";
                  $temp3 = @mysqli_query($connect , $q1);
                  $temp4 = @mysqli_fetch_row($temp3);
                  $city  = $temp4[0];
  
                  $ads['city']    = $city;    
                  $ads['cat'] = $cat;         
  
                  array_push( $response['ads'] , $ads);
              }
          }
          else
          {
              $response['success'] = 0;
              $response['message'] = "nothing";
          }
  
          echo( json_encode( $response ) );
  
          /* I don't want use JSON_PRETTY_PRINT. If you want, you know! */
  
          @mysqli_close( $connect );
      }
  }
  
  function ago( $datetime )
  {
  
  $interval = date_create('now')-&gt;diff( date_create($datetime) );
  if ( $v = $interval-&gt;y &gt;= 1 ) {
      $in = ($interval-&gt;y == 1) ? ' سال قبل' : ' سال قبل';
      return $interval-&gt;y . $in;
  }
  if ( $v = $interval-&gt;m &gt;= 1 ) {
      $in = ($interval-&gt;m == 1) ? ' ماه قبل' : ' ماه قبل';
      return $interval-&gt;m . $in;
  }
  if ( $v = $interval-&gt;d &gt;= 1 ) {
      $in = ($interval-&gt;d == 1) ? ' روز قبل' : ' روز قبل';
      return $interval-&gt;d . $in;
  }
  if ( $v = $interval-&gt;h &gt;= 1 ) {
      $in = ($interval-&gt;h == 1) ? ' ساعت قبل' : ' ساعت قبل';
      return $interval-&gt;h . $in;
  }
  if ( $v = $interval-&gt;i &gt;= 1 ) {
      $in = ($interval-&gt;i == 1) ? ' دقیقه قبل' : ' دقیقه قبل';
      return $interval-&gt;i . $in;
  }
  $in = ($interval-&gt;s == 1) ? ' ثانیه قبل' : ' ثانیه قبل';
  return $interval-&gt;s . $in;
  }   
  ?&gt;
  </code></pre>