Can't Mix MySQL APIs in PHP
Can you mix MySQL APIs in PHP? This question has prompted discussion online, with some claiming it's possible to use both mysql_ and mysqli_ APIs simultaneously. Let's dive into the issue and explore the limitations:
In one example provided, the code appears to connect using mysqli_connect() and close the connection using mysql_close(), raising a warning. This is because these APIs utilize distinct resources incompatible with each other.
In another attempt, mysqli_close() was used, but the warning persisted.
Key Points:
To verify a connection's validity, you can use if (mysqli_connect_errno($con)) { ... } to check for connection errors.
The above is the detailed content of Can I Mix `mysql_` and `mysqli_` APIs in PHP?. For more information, please follow other related articles on the PHP Chinese website!