How to change mysql to mysqli?

The first thing to do would probably be to replace every mysql_* function call with its equivalent mysqli_*, at least if you are willing to use the procedural API — which would be the easier way, considering you already have some code based on the MySQL API, which is a procedural one. To help with … Read more

mysqli or die, does it have to die?

Does it have to die Quite contrary, it shouldn’t or die() ever. PHP is a language of bad heredity. Very bad heredity. And or die() with error message is one of the worst rudiments: die throws the error message out, revealing some system internals to the potential attacker such error message confuses casual users, because … Read more

How to deal with mysqli problems? mysqli_fetch_array(): Argument #1 must be of type mysqli_result

TL;DR Always have mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); in your mysqli connection code. It will let MySQL tell you what the actual problem is, be it with query, server, database or whatever. 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 … Read more