The goal of the question is to have one or more well-crafted answers to serve as a reference when using the extension mysql_*
in code.
Answering questions here on Stackoverflow I am surprised by the number of users who continue to maintain code that includes the API or extension mysql_*
to handle the data, despite the fact that in the PHP Manual it says the following:
This extension is deprecated as of PHP 5.5.0, so it has been removed as of PHP 7.0.0. The mysqli or PDO_MySQL extension should be used instead . See also the MySQL API Overview for help choosing a MySQL API.
That means the functions:
mysql_result
mysql_select_db
mysql_num_rows
mysql_connect
mysql_db_query
mysql_fetch_assoc
mysql_*... todas las que empiecen así ...
.
All of these features, and many others listed here , should be avoided.
To add insult to injury, the functions are almost identical to those of the extension mysqli
, which is recommended in conjunction with PDO. The only difference between the deprecated functions listed above and MySQLi's is the letter i
before the underscore _
.
So the question is this: What are the main serious reasons why I should stop using the extension mysql_*
to query my data?
PS: I am willing to reward one or several good answers.