Can I mix MySQL APIs in PHP?
Just to give a general answer here about all three MYSQL API's with a reference:
You can't mix any of the three (mysql_*
, mysqli_*
, PDO
) MYSQL API's from PHP together, it just doesn't work. It's even in the manual FAQ:
It is not possible to mix the extensions. So, for example, passing a mysqli connection to PDO_MySQL or ext/mysql will not work.
You need to use the same MySQL API and its related functions, from connection to querying.
Technically you can use as many separate connections as you want, while your problem is caused by a mere typo - you only cannot use resources from one extension with functions from another, which is quite obviously.
However, you should avoid multiple connections from the same script, no matter from single API or different ones. As it will burden your database server and exhaust its resources. So, although technically you can, you shouldn't mix different extensions in your code, save for the short period of refactoring.