Possible Duplicate:
Why shouldn’t I use mysql_* function in PHP?
I am looking at using Justin Vincent's ezSQL in my next PHP project, and I noticed that it uses mysql_connect
under the hood. I know that it is not recommended to use the mysql_*
functions in PHP anymore. I have seen my fair share of websites that were SQL injection-attacked through code like the following:
<?php mysql_qyery("SELECT * FROM my_table WHERE id = " . $_GET['id']); ?>
I know that PDO has support for prepared statements, but you are not forced to prepare your statements, so you could still write similarly insecure queries.
I was wondering if there are any intrinsic security flaws with the mysql_*
functions that I should be aware of if I am using a library like exSQL that handles escaping data before executing a query?
Edit: I am not asking whether I should use PDO/mysqli instead of the mysql extension or whether the mysql extension will be removed in future versions of PHP. The answers to both of these questions are readily available on the PHP manual as well as elsewhere. However, there is a lack of readily-available documentation as to why the mysql extension is discouraged. This is evident by the fact that the PHP manual's answer to the question, "Why is the MySQL extension (ext/mysql) that I've been using for over 10 years discouraged from use? Is it deprecated? What do I use instead? How can I migrate?" does not in fact answer why it is discouraged.
This is a problem for developers using libraries that still rely on the old mysql extension. Just because the extension is no longer supported does not make this an "irrelevant" question, as there are still plenty of libraries that use the old extension.