Search code examples
phpmysqlmysqlisql-like

How to use LIKE in MySQLi?


I have a code it's working with MysQl but does not work in MySQLi:

function CheckBlocked($table, $thisip, $service) {
    $sql="SELECT * FROM $table WHERE code = '$service' AND b_contents LIKE '%.$thisip.%'";
    $query=mysqli_query($dbconnect,$sql);
    $num=mysqli_num_rows($query);
    if ($num > 0) {
        return true;
    } else {
        return false;
    }
}

How to used in MySQLi ?


Solution

  • try this code :

     $sql="SELECT * FROM $table WHERE code = '$service' AND b_contents LIKE '%".$thisip."%' ";