News Feed
Jobs Feed
Sections

Recent Jobs

News Archive
Ilia Alshanetsky's Blog:
mysql_real_escape_string() versus Prepared Statements
January 23, 2006 @ 06:58:18

Ilia Alshanetsky also has hos own look today at the "mysql_real_escape_string versus addslashes" debate that's going on, looking more at why there's even an issue here (with addslashes).

Chris has written a compelling piece about how the use of addslashes() for string escaping in MySQL queries can lead to SQL injection through the abuse of multibyte character sets. In his example he relies on addslashes() to convert an invalid multibyte sequence into a valid one, which also has an embedded ' that is not escaped. And in an ironic twist, the function intended to protect against SQL injection is used to actually trigger it.

The problem demonstrated, actually goes a bit further, which even makes the prescribed escaping mechanism, mysql_real_escape_string() prone to the same kind of issues affecting addslashes().

He shows code examples, creating a simple SQL injection that uses mysql_real_escape_string to cause the same issue - all based around the default characterset that the MySQL server uses. His suggested solution? Prepared statements... (like what things such as PDO offer)

1 comment voice your opinion now!
php addslashes mysql_real_escape_string debate prepared statements php addslashes mysql_real_escape_string debate prepared statements




Similar Posts

Wez Furlong\'s Blog: Upcoming Conference Appearances

Codewalkers.com: Book Review - PHP Unleashed

PHPied.com: Getting an RSS feed with the Zend framework 0.1.1

Tobias Schlitt's Blog: PHP at FrOSCon program available!

David Sklar\'s Blog: Parsing Reasonably-sized HTTP Responses


Community Events









Don't see your event here?
Let us know!


mysql code example zendframework zend developer PHP5 conference job package PEAR database cakephp book releases framework ajax application release security

All content copyright, 2009 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework