There's a lot of related questions coming in so this request makes sense, but on second thought, I'm starting to think it doesn't really matter whether we tell people not to use mysql
or not.
The vast majority of users who present mysql_* code have copy-pasted it from some crappy tutorial and are going through the first steps of learning programming. They will not heed the PDO advice. They will not add error checking to their code. They just want to know why it doesn't work and what they need to do to make it work.
If they eventually evolve professionally, they will find out that it's deprecated quickly enough (e.g. by looking in the manual). SO can't be responsible for every crappy tutorial out there. I mean, W3Schools sports SQL injection vulnerabilities in its examples to this day.
Look at this work of beauty for example:
$q=$_GET["q"];
... some code in which they connect to the DB, but do NOT escape $q ......
$sql="SELECT * FROM user WHERE id = '".$q."'";
$result = mysql_query($sql);
That infernal piece of crap site alone leads to more bad code than SO can ever fix.
mysql_
functions get special treatment? Shouldn't the site automatically warn you when you're usingsplit
? or any of the other hundreds of deprecated PHP functions? And why stop at PHP? What about deprecation warnings for Perl? Ruby? Python? C? Why stop at deprecation warnings? And what about false-positives, where somebody asks "I've heard that themysql_*
functions are, bad what should I use to replace them?" And who decides on which specific functions get a warning and which don't? Who maintains the list of deprecated functions? – meagar Aug 13 '12 at 21:29