0

I'm working on Android apps that showing the output of table in SQL from PHP file, the problem is this PHP file won't show anything in output.

I have tried to find the solution all over Internet but can't find any.

This is the source code:

<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    $email = $_POST['user_email'];

    require_once 'DB_Connect.php';
    $db = new DB_Connect();

    $response = array();

    $sql = ("SELECT * FROM white_list WHERE user_email = '" . $email . "'");
    $result = mysqli_query($db->connect(), $sql) or die(mysqli_error());

    $no_of_rows = mysqli_num_rows($result);

    if ($no_of_rows > 0) {
        $response["white_list"] = array();

        while ($row = mysqli_fetch_array($result)) {
            $white_list            = array();
            $white_list["name"]    = $row["wl_name"];
            $white_list["hp"]      = $row["wl_hp"];
            $white_list["address"] = $row["wl_address"];
            $white_list["link"]    = $row["wl_link"];

            array_push($response["white_list"], $white_list);
        }
        $response["success"] = 1;
        echo json_encode($response);
    } else {
        $response["success"] = 0;
        $response["message"] = "No Data";

        echo json_encode($response);
    }
}
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
Shane
  • 1
  • 2
  • 3
    [Little Bobby](http://bobby-tables.com/) says [your script is at risk for SQL Injection Attacks](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php). Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php). Even [escaping the string](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) is not safe! – [Jay Blanchard](http://stackoverflow.com/users/1011527/jay-blanchard) – Jeff Puckett May 26 '16 at 15:22
  • The code looks like it should work. Are you getting the `No Data` response? – Barmar May 26 '16 at 15:57
  • Check the raw AJAX response in the Network tab of Developer Tools to see what actually is being returned. – Barmar May 26 '16 at 15:58
  • Yeah, i did get no data response, is it because the method? – Shane May 27 '16 at 06:31

0 Answers0