I am using jqGrid from guriddo and want to create a query with LIKE in it dynamically. I have the following code:

```
$sql = "SELECT * FROM users";
if (isset($_SESSION['search']))
{
    $temp = $_SESSION['search'];
    $sql .= " WHERE users.name LIKE %".$temp."%";
}
$grid->SelectCommand = $sql;

```

But this gives me the following error:

> 
> SQLSTATE[42000]: Syntax error or access violation: 1064 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 '%'Adam'% LIMIT 0, 0' at line 9
> 
> 
>