There was no choice but to switch to MySQLi, as the old mysql extension was out of date. Also, when developing the old extension, we had tried to make it compatible with previous versions, so that the code was difficult to update , since it dates from the beginning of PHP and MySQL and, in part, had not been developed from the better way.
If, for example, no connection resources were explicitly specified, all functions tried to use the last connection that occurred. In the worst case, mysql_query () could even access a totally different database. The connection identifier was optional in the old extension, while in the new one it must be specified. Prepared statements have also been added, which make reading the data from the database faster and more secure.
Fortunately, many functions can be modified simply by adding an i to the mysql () function . However, there are some differences between the two extensions.
Snippet : connection identifier in MySQL and MySQLi
Some mysqli () functions require a connection identifier, that is, a PHP variable generated when connecting to the database. In the example below, it will be $ link .