Json parser problem

juanjo3691

Member
Licensed User
Longtime User
Hello, My php file

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
$databasehost = "localhost";
$databasename = "musimple_misnotas";
if(isset($_GET['user'])){
$databaseusername = $_GET['user'];
}
if(isset($_GET['pass'])){
$databasepassword = $_GET['pass'];
}

$query = file_get_contents("php://input");
$con = mysql_connect($databasehost,$databaseusername,$databasepassword) or die(mysql_error());
mysql_select_db($databasename) or die(mysql_error());
$sth = mysql_query($query);

if (mysql_errno()) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysql_error();
}
else
{
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
}
?>
</body>
</html>

it returns one string and with the string.Getstring(UTF8) option i have this:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
[{"ID":"1","EMAIL":"[email protected]","NAME":"abcd","PASS":"123456"}]
</body>
</html>

When i execute the line
CursorRemoto = Parser.NextArray
the program return an error:
java.lang.RuntimeException: JSON Array expected.

Does anybody knows which is the problem ?
 
Top