The first thing to do would probably be to replace every mysql_*
function call with its equivalent mysqli_*
, at least if you are willing to use the procedural API -- which would be the easier way, considering you already have some code based on the MySQL API, which is a procedural one.
To help with that, the MySQLi Extension Function Summary is definitely something that will prove helpful.
For instance:
mysql_connect
will be replaced by mysqli_connect
mysql_error
will be replaced by mysqli_error
and/or mysqli_connect_error
, depending on the contextmysql_query
will be replaced by mysqli_query
Note: For some functions, you may need to check the parameters carefully: Maybe there are some differences here and there -- but not that many, I'd say: both mysql and mysqli are based on the same library (libmysql ; at least for PHP <= 5.2)
For instance:
mysql_select_db
once connected, to indicate on which database you want to do your queriesmysqli_connect
.mysqli_select_db
function that you can use, if you prefer.