by smacktoward · 13y ago · 0 comments
Actually you should avoid using both mysql_pconnect and mysql_connect, because they're both functions from the deprecated old mysql library of database functions. The preferred way to deal with MySQL databases in 2012 is to use either PDO (http://php.net/manual/en/book.pdo.php) or the "improved MySQL" library (http://php.net/manual/en/book.mysqli.php), both of which are better architected and give you access to things like prepared statements that the old mysql library does not.
There's really no good reason to be using the old mysql library at this point. Unfortunately, however, there's a vast amount of ancient PHP tutorials, code snippets, and other copypasta floating around out there that uses it, so people who don't know better still pick it up.
PHP's libraries are full of Legacy Cruft that any other sane system would have deprecated and eliminated during a major revision transition.
The wholly inefficient and unsafe legacy MySQL lib is one of the primary examples.
Good on you for at least mentioning parameterized statements, but you didn't really follow through. You then go on to confuse the situation by talking about the old API.
Instead, you should have just said "Using this old API is a horrible idea. Don't. Ignore every guide or tutorial that does."
PHP has evolved considerably from its roots. The #1 problem with PHP is that it still lives in its parent's basement and hangs out with the same losers it met in Kindergarten.
Script kiddies everywhere will "benefit".