title: SyntaxError: JSON.parse: unexpected end of data at line 2 column 1 of the JSON data
body: <p>I am trying to run a script that would take in 3 variables using "GET" and then return the result back to the activity calling the script. I have written my php code and am trying to test it using postman, but every time i give it arguments it returns = unexpected ''</p>
  
  <p>here is my php code:</p>
  
  <pre><code>&lt;?php
  require_once 'connection.php';
  header('Content-Type: application/json');
  
  
  class User{
      private $db; 
      private $connection;
      function __construct(){
      $this-&gt;db = new DB_connection();
      $this-&gt;connection = $this-&gt;db-&gt;get_connection();
      }
      public function transaction($emailval, $merchantid, $amount){
          $query= "select amount from wallet_user where email = '$emailval'";
          $result = mysqli_query($this-&gt;connection, $query);
          $row=$result-&gt;fetch_assoc();
          $resultval = floatval($row['amount']);
          //echo resultval;
          if ($resultval &gt;= $amount){
              $sql = "Select * from wallet_merchant where merchant_id = '$merchantid'";
              $resultm = mysqli_query($this-&gt;connection, $sql);
  
              if (mysqli_num_rows($resultm) &gt; 0) { 
                  $query2 = "UPDATE finger.wallet_merchant SET amount = amount + $amount WHERE merchant_id= '$merchantid' ;";
                  $query3 = "UPDATE finger.wallet_user SET amount = amount - $amount WHERE email= '$emailval' ;";
  
                  $result2 = mysqli_query($this-&gt;connection, $query2);
                  $result3 = mysqli_query($this-&gt;connection, $query3);
  
                  $json['tsuccess'] = 'Transaction successful!';
                  echo json_encode ($json);
                  mysqli_close($this-&gt;connection);
              }
          }
          else{
              $json['amounterr'] = 'Please add more amount to your wallet!';
              echo json_encode ($json);
              mysqli_close($this -&gt;connection);
              }
      }
  }
  
  $user = new User();
  
  if (isset ($_GET['emailval'], $_GET ['merchant_id'], $_GET['amount'] )){
      $emailval = $_GET['emailval'];
      $merchantid = $_GET['merchant_id'];
      $amount = floatval($_GET['amount']);
      if (!empty ($emailval) &amp;&amp; !empty($merchantid) &amp;&amp; !empty($amount)){
          $user-&gt;transaction($emailval, $merchantid, $amount);
      } 
      else{
          echo json_encode("Please enter both fields!");
      }
  }
  
  ?&gt;
  </code></pre>
  
  <p>I don't understand what I'm missing here. It's not the connection.php script that's giving me any error because i'm running other scripts on it and they run fine, what am i missing?</p>