So I have this PHP script that let me get photo objects from MySQL database, while fetching the results with mysql_fetch_array() function I push the row into an array. Which works, simple and good.
After the while, I do an echo of the array size and it does work too. Then, when I try to encode the array to json format and I test it I get "Response does not contain any data" with a Ok status from Chrome's Advanced Rest Client.
if (mysql_num_rows($result) > 0)
{
// looping through all results
// photo node
$response["photos"] = array();
while ($row = mysql_fetch_array($result)) {
// temp photo array
$photo = array();
$photo["photoid"] = $row["photoid"];
$photo["photodescription"] = $row["photodescription"];
$photo["uploaderid"] = $row["uploaderid"];
$photo["takenat"] = $row["takenat"];
$photo["nblikes"] = $row["nblikes"];
$photo["photourl"] = $row["photourl"];
$photo["thumbnailurl"] = $row["thumbnailurl"];
// push single photo into final response array
array_push($response["photos"], $photo);
}
// success
$response["success"] = 1;
// echoing JSON response
echo sizeof($response["photos"]);
echo json_encode($response);
}
Can anyone help, please ?
CURSEof theCORS