1

I have lerant about android and MySQL, and I have view about this web:http://codeoncloud.blogspot.tw/2013/07/android-mysql-php-json-tutorial.html

but I don't know how to solve this problem: enter image description here

<?php  
$host="sql113.byethost14.com"; //replace with database hostname 
$username=" xxx  "; //replace with database username 
$password=" xxx  "; //replace with database password 
$db_name="b14_16972597_food"; //replace with database name

$con=mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
$sql = "select * from emp_info"; 
$result = mysql_query($sql);
$json = array();

if(mysql_num_rows($result)){
while($row=mysql_fetch_assoc($result)){
$json['emp_info'][]=$row;
}
}
mysql_close($con);
echo json_encode($json);  
?>
John Joe
  • 12,412
  • 16
  • 70
  • 135
  • 1
    The response is a html page, that's why you have that exception. Could you post the entire response? Check it in your browser. – cylon Dec 27 '15 at 15:41

1 Answers1

0

You solve this by returning a valid JSON string.

You can use a service to check its validity:

http://jsonlint.com/

Your script should return JSON and only a JSON string nothing else.

To debug this in your app you should log the string and check it before even attempting to convert it JSON.

meda
  • 45,103
  • 14
  • 92
  • 122