title: send json data from php
body: <p>I am totally new to Php and i am trying to send json data from php to android.I have the following code in php to read value from data base:</p>
  
  <pre><code>&lt;?php
  $con=mysql_connect("localhost","root","");
  
  if(! $con)
  {
          die('Connection Failed'.mysql_error());
  }
  
  mysql_select_db("registration",$con);
  $name="Adam";//$_POST["name"];
  $password="charles";//$_POST["password"];
  $sql="SELECT * FROM users WHERE name='$name'and password='$password'"; 
  
  $result=mysql_query($sql, $con);
  while($row = mysqli_fetch_array($result))     
  {
      $details= array(
          'name' =&gt; $row['name'],
          'password' =&gt; $row['password'],
  
      );
      array_push($json, $bus);
  }
  
  $jsonstring = json_encode($json);
  echo $jsonstring;
  mysql_close();
  ?&gt;
  </code></pre>
  
  <p>I am expecting the output to be something like this:</p>
  
  <pre><code>[{"name":"Adam","age":"25","surname":"charles"}]
  </code></pre>
  
  <p>If i am not wrong the JSON data.
  But this gives me error :</p>
  
  <pre><code>mysqli_fetch_array() expects parameter 1 to be mysqli_result, resource given in...
  </code></pre>
  
  <p>and also </p>
  
  <pre><code>Undefined variable: json in...
  </code></pre>
  
  <p>can somebody pleease tell me what might be the possible error</p>