Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL query in php file error
    primarykey
    data
    text
    <p>I have this code passing a variable from a url. When i use $_GET method it returns me a json with no products found but when i give manually the the value that $user_email has from the url it returns me the correct json! what is wrong and how can i correct it? thank you</p> <p>URL: http://<strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em>*</strong>/android_connect/get_all_products.php?user_email=m</p> <pre><code>&lt;?php /* * Following code will list all the products */ // array for JSON response $response = array(); $user_email= $_GET['user_email']; // include db connect class require_once __DIR__ . '/db_connect.php'; // connecting to db $db = new DB_CONNECT(); // get all products from products table $test= "SELECT *FROM products WHERE user_email= '" .$user_email. "'"; //echo $test; $result = mysql_query($test) or die(mysql_error()); // check for empty result if (mysql_num_rows($result) &gt; 0) { // looping through all results // products node $response["products"] = array(); while ($row = mysql_fetch_array($result)) { // temp user array $product = array(); $product["pid"] = $row["pid"]; $product["firstname"] = $row["firstname"]; $product["lastname"] = $row["lastname"]; $product["email"] = $row["email"]; $product["phone"] = $row["phone"]; $product["address"] = $row["address"]; $product["created_at"] = $row["created_at"]; $product["updated_at"] = $row["updated_at"]; $product["user_email"] = $row["user_email"]; // push single product into final response array array_push($response["products"], $product); } // success $response["success"] = 1; // echoing JSON response echo json_encode($response); } else { // no products found $response["success"] = 0; $response["message"] = "No products found"; // echo no users JSON echo json_encode($response); } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload