title: return Json array from PHP mySQL - Error
body: <p>Here is my php code and i want to get JSON array relevant to to my $_GET("ProductGroup") variable. but when i log in to the page by submitting parameters via URL
  <a href="http://iilsfa.br0s.info/SFA/get_all_products.php?%27Laptops%27" rel="nofollow">http://iilsfa.br0s.info/SFA/get_all_products.php?%27Laptops%27</a> it displays this error.</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1</p>
  </blockquote>
  
  <p>i could not find where the error is. please help</p>
  
  <pre><code>&lt;?php
   include_once './db_connect.php';
  
  function getProducts(){
  $db = new DB_CONNECT();
  // array for json response
  $response = array();
  $response["products"] = array();
  
  // Mysql select query
  
  // check for post data
   if (isset($_GET["ProductGroup"])) {
  $selected_group = $_GET['ProductGroup'];
  }
  
  
  $result = mysql_query("SELECT * FROM Product WHERE ProductType= $selected_group")or die(mysql_error());
  
  
  while($row = mysql_fetch_array($result)){
      // temporary array to create single category
  
      $tmp = array();
      $tmp["id"] = $row["ProductID"];
      $tmp["name"] = $row["ProductName"];
      $tmp["type"] = $row["ProductType"];
      $tmp["image"] = $row["ProductImage"];
      $tmp["des"] = $row["ProductDescription"];
  
  
      // push category to final json array
      array_push($response["products"], $tmp);
  }
  
  // keeping response header to json
  header('Content-Type: application/json');
  
  // echoing json result
  echo json_encode($response);
   }
  
   getProducts();
   ?&gt;
  </code></pre>
  
  <p>PS- I have changed my sql query to this</p>
  
  <pre><code>$result = mysql_query("SELECT * FROM Product WHERE ProductType=   '".mysql_real_escape_string('$selected_group')."'")or die(mysql_error());
  </code></pre>
  
  <p>Now its not displaying the previous error.but showing an empty json string. i have checked SQL query with phpmyAdmin.it working correctly and produce results..</p>