Change syntax from mysqli to mysql


I found this code in internet, and i want to used it , but my database is mysql not mysqli, how can I change my syntax.

<?php    $db = new mysqli('DB_HOST', 'USERNAME' ,'PASSWORD', 'DATABASE_NAME');
       if(!$db) {     
      echo 'Could not connect to the database.'; 
    } else {   
        if(isset($_POST['queryString'])) {  
           $queryString = $db->real_escape_string($_POST['queryString']);   
            if(strlen($queryString) >0) {         
          $query = $db->query("SELECT country FROM countries WHERE country LIKE '$queryString%' LIMIT 10");   
              if($query) {  
               echo '<ul>';               
      while ($result = $query ->fetch_object()) {      
                   echo '<li onClick="fill(\\''.addslashes($result->country).'\\');">'.$result->country.'</li>';              
  echo '</ul>';                 
  } else {                 
    echo 'OOPS we had a problem <IMG class=wp-smiley alt=:( src=""> ';        
  } else {     
            // do nothing        
  } else {          
   echo 'There should be no direct access to this script!';   
 } ?>

Thank you

The database is mysql.

mysql_ and mysqli_ are both PHP database extensions. Another main one is PDO. Comparison of features (at the end of the page).

You should be able to use mysqli_ without any problems. Did you try?

I used mysql , and no mysqli in my php…

With all the security issues that mysql_ has that are fixed in mysqli_ and PDO plus the fact that all supported versions of PHP now support mysqli_ there is no reason for not updating all your database accesses to use the new interface. Even if you don’t immediately rewrite all the calls to remove the security holes, changing everything to use either mysqli_ or PDO will at least make it possible to make those security changes as and when you get around to it without having to change all your scripts at once.

Future versions of PHP will probably drop support for mysql_ completely - it already is optional whether it gets installed or not.