Re: Single Quotes in Form Inputs

From: Date: Tue, 28 Jul 2009 05:40:43 +0000
Subject: Re: Single Quotes in Form Inputs
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-295910@lists.php.net to get a copy of this message
You can use http://us.php.net/mysql_real_escape_string to escape the input. [8<]
You should prep your data for insertion into the data by using a tool that formats it strictly for the database. In the ops case mysql_real_escape_string() is the correct tool for the job.
What about using prepared statements? This is my preferred method of "escaping output" when I'm using variables in a database query. Of course the ease and convenience of this method will depend to a great extent on what version of PHP is available on the server. For the OP, have you read up much on SQL injection? If not, here's a decent place to start: http://www.owasp.org/index.php/SQL_injection Ben

« previous php.general (#295910) next »