Bonjour,

J'ai écrit un script PHP, ci-dessous, qui devrait me retourner une liste de photos. Mais à chaque fois que j'essaie de le tester avec l'extension Advanced Rest Client de Chrome, on me retourne ce message "Response does not contain any data." Avec un statut 200 Ok.
Quand je teste ma requête dans PhpMyAdmin elle marche parfaitement.
Quel est le problème s'il vous plait.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
 
<?php
 
/*
 * Following code will list all the photos
 */
 
// array for JSON response
$response = array();
 
// include db connect class
require_once __DIR__ . './../db_connect.php';
 
// connecting to db
$db = new DB_CONNECT();
 
// get all photos from photo table
$result = mysql_query("SELECT * FROM photo ORDER BY nblikes DESC") or die(mysql_error());
 
// check for empty result
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 json_encode($response);
} else {
    // no photos found
    $response["success"] = 0;
    $response["message"] = "No photos found";
 
    // echo no photos JSON
    echo json_encode($response);
}
?>