View Single Post
Old 09-19-2007, 09:04 PM   #9 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,377
Thanks: 5
Salathe is on a distinguished road
Default

To to clarify Wildhoney's post. You don't want to mysql_real_escape_string the entire SQL query all in one go. It is only intended to escape portions of user input (generally the values of columns).

PHP Code:
$szTitle = ...  (from $_POST$_GETetc?)
$szSafeSQL sprintf('SELECT * FROM myTable WHERE title = "%s"'
                     
mysql_real_escape_query($szTitle)); 
Salathe is offline  
Reply With Quote