Can I mix MySQL APIs in PHP?
No, you can’t use mysql and mysqli together. They are separate APIs and the resources they create are incompatible with one another. There is a mysqli_close, though.
No, you can’t use mysql and mysqli together. They are separate APIs and the resources they create are incompatible with one another. There is a mysqli_close, though.
You can’t have two simultaneous queries because mysqli uses unbuffered queries by default (for prepared statements; it’s the opposite for vanilla mysql_query). You can either fetch the first one into an array and loop through that, or tell mysqli to buffer the queries (using $stmt->store_result()). See here for details.
Sounds like you just need to install MySQLi. If you think you’ve done that and still have a problem, please post your operating system and anything else that might help diagnose it further.
Please read the user notes for this method: http://php.net/manual/en/mysqli-stmt.get-result.php It requires the mysqlnd driver… If it isn’t installed on your webspace you will have to work with bind_result() & fetch()!
There are (more than) three popular ways to use MySQL from PHP. This outlines some features/differences PHP: Choosing an API: (DEPRECATED) The mysql functions are procedural and use manual escaping. MySQLi is a replacement for the mysql functions, with object-oriented and procedural versions. It has support for prepared statements. PDO (PHP Data Objects) is a … Read more
TL;DR Always have mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); in your mysqli connection code and always check the PHP errors. Always replace every PHP variable in the SQL query with a question mark, and execute the query using prepared statement. It will help to avoid syntax errors of all sorts. Explanation Sometimes your MySQLi code produces an error … Read more
If you have a look at MySQL Improved Extension Overview, it should tell you everything you need to know about the differences between the two. The main useful features are: an Object-oriented interface support for prepared statements support for multiple statements support for transactions enhanced debugging capabilities embedded server support.
Well, you could argue with the object oriented aspect, the prepared statements, the fact that it becomes a standard, etc. But I know that most of the time, convincing somebody works better with a killer feature. So there it is: A really nice thing with PDO is you can fetch the data, injecting it automatically … Read more