I'm trying to change my code to mysqli, I heard mysql isn't recommended and  I'm having trouble changing my code to mysqli.
I managed to connect to my database but the rest of the code doesn't seem to work, I tried changing all mysql to mysqli but it didn't work. What could I do so the code works the same but in mysqli?
Could someone rewrite it so I could see the difference. I haven't seen any good tutorials.
<?php
 $db = new mysqli('localhost','root', '', 'searchengine');
    if($db->connect_errno) {
        die('sorry we are having some problbems');
        }
$sql = mysql_query(sprintf(
    "SELECT * FROM searchengine WHERE pagecontent LIKE '%s' LIMIT 0,%d",
        '%'. mysql_real_escape_string($_GET['term']) .'%',
        mysql_real_escape_string($_GET['results']))
);
while($ser = mysql_fetch_array($sql)) {
    echo "<h2><a href='$ser[pageurl]'>$ser[pageurl]</a></h2>";
}
mysql_close();
 
     
     
    