So, you are trying to migrate a codebase from the deprecated MySQL extension to MySQLi. You’ve carefully changed all the
mysql_* function calls to the corresponding
mysqli_*. You run your code and….
Your data access code is not working anymore and your output is now littered with warnings like:
PHP Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in...
PHP Warning: mysqli_query() expects exactly 2 parameters, 1 given in...
PHP Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in...
What exactly is going on here, and what can you do about it?
The short answer is that, even though the functions of the MySQL extension and MySQLi are very similar, there are subtle but important differences in the signatures of some of the functions.
More specifically, the
For a more detailed answer, including some other problems you need to be on the lookout for when converting to MySQLi, see: Hidden Reasons Why Migrating from MySQL to MySQLi Procedural may not be as Simple as You Think
Did this help you?
Sign up for my newsletter and I will send you regular articles and other usefull stuff.
You can unsubscribe at any time