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);  
?>
1
  • 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. Commented Dec 27, 2015 at 15:41

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.