title: jqgrid toolbar search not getting filters for mysql
body: <p>this may have been answered before but i have not found something working for me.</p>
  
  <p>i am trying to implement the toolbar search option for jqgrid with php/json data.</p>
  
  <p>so far i have the following </p>
  
  <pre><code>&lt;script src="js/jquery-1.11.0.min.js"&gt;&lt;/script&gt;
  &lt;script type='text/javascript' src='js/jquery-ui-1.8.4.custom.min.js'&gt;&lt;/script&gt;        
  &lt;script type='text/javascript' src='js/i18n/grid.locale-es.js'&gt;&lt;/script&gt;
  &lt;script type='text/javascript' src='js/jquery.jqGrid.min.js'&gt;&lt;/script&gt;
  
  &lt;script&gt;
  $(document).ready(function () {
  $("#list_records").jqGrid({
  url: "grid.php",
  datatype: "json",
  mtype: "GET",
  colNames: ["ID", "Encuesta", "Fecha", "Quien"],
  colModel: [
  { name: "id_consulta"},
  { name: "texto"},
  { name: "fecha"},
  { name: "quien"}
  ],
  pager: "#perpage",
  rowNum: 10,
  rowList: [10,20],
  sortname: "id_consulta",
  sortorder: "asc",
  height: 'auto',
  viewrecords: true,
  gridview: true,
  caption: ""
  });
  
  $('#list_records').jqGrid('filterToolbar', {stringResult: true, searchOnEnter: false, defaultSearch : "bw"});
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>i set the stringresult: true and tried to get the filters.</p>
  
  <p>the correpsonding php file is</p>
  
  <pre><code>$db = mysql_connect($server,$user,$pass);
  mysql_select_db($dbname,$db);
  
      $page = $_REQUEST['page']; // get the requested page
      $limit = $_REQUEST['rows']; // get how many rows we want to have into the grid
      $sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort
      $sord = $_REQUEST['sord']; // get the direction
      if(!$sidx) $sidx =1;
  
  
  $filterResultsJSON = json_decode($_REQUEST['filters']);
  
  $filterArray = get_object_vars($filterResultsJSON);
  
  $counter = 0;
  $sql='';
  while($counter &lt; count($filterArray['rules']))
  {
  $filterRules = get_object_vars($filterArray['rules'][$counter]);
  
  if($counter == 0){
  $sql .= ' WHERE ' . $filterRules['field'] . ' LIKE "%' . $filterRules['data'] . '%"';
  }
  else {
  $sql .= ' AND ' . $filterRules['field'] . ' LIKE "%' . $filterRules['data'] . '%"';
  }
  $counter++;
  }
  
  $totalrows = isset($_REQUEST['totalrows']) ? $_REQUEST['totalrows']: false;
  if($totalrows) {$limit = $totalrows;}
  
  $result = mysql_query("SELECT COUNT(*) AS count FROM consulta $sql"); 
  $row = mysql_fetch_array($result,MYSQL_ASSOC); 
  
  $count = $row['count']; 
  if( $count &gt; 0 &amp;&amp; $limit &gt; 0) { 
  $total_pages = ceil($count/$limit); 
  } else { 
  $total_pages = 0; 
  } 
  if ($page &gt; $total_pages) $page=$total_pages;
  $start = $limit*$page - $limit;
  if($start &lt;0) $start = 0; 
  
  $SQL = "SELECT * FROM consulta $sql ORDER BY $sidx $sord LIMIT $start , $limit"; 
  $result = mysql_query( $SQL ) or die("Couldn't execute query.".mysql_error()); 
  
  $i=0;
  while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
  $responce-&gt;rows[$i]['id']=$row['id_consulta'];
  $responce-&gt;rows[$i]['cell']=array($row['id_consulta'],utf8_encode($row['texto']),$row['fecha'],$row['quien']);
  $i++;
  }
  
  echo json_encode($responce);
  </code></pre>
  
  <p>i am getting the following error message upon calling the php directly
  Warning: get_object_vars() expects parameter 1 to be object, null given in /home/www2w/public_html/tuvoto/grid.php on line 16
  Couldn't execute query.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>
  
  <p>any help apreciated</p>