P粉6638838622023-07-28 14:28:35
(I realize this is an old question, but it still comes up often...)
If you do replace mysql_* with mysqli_*, keep in mind that many mysqli_* functions require passing a database connection.
For example:
mysql_query($query)
became:
mysqli_query($link, $query)
In other words, a lot of checks are required.
P粉1327308392023-07-28 11:14:09
First, you may want to replace each mysql_* function call with its corresponding mysqli_* function, at least if you are willing to use the procedural API - considering you already have some code based on the MySQL API, this will be Easier way since MySQL API is procedural.
To help you, the MySQLi extension function summary will undoubtedly be very helpful.
For example:
mysql_connect will be replaced by mysqli_connect.
mysql_error will be replaced with mysqli_error and/or mysqli_connect_error depending on the context.
mysql_query will be replaced with mysqli_query.
NOTE: For some functions you may need to double check the parameters: there may be some slight differences, but I would say not much: both mysql and mysqli are based on the same library ( libmysql; at least for PHP <= 5.2).
For example:
After completing these steps, try executing the new version of your script...and check if everything is working; if not...then it's time to find the bug ;-)