Re: Slashes or no slashes

From: Date: Tue, 24 Aug 2010 06:13:28 +0000
Subject: Re: Slashes or no slashes
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14  Groups: php.db 
Request: Send a blank email to php-db+get-47329@lists.php.net to get a copy of this message
In the case that your comparing a field to a field in the database (the field name) do you escape that or because it is hardcoded you dont need to? My thoughts are that you need to escape all data going in.
Correct. A field name is not data though. You've already validated it (somehow, either by hardcoding it, or checking it against field names to make sure it's a proper field and doesn't contain weird chars).
But I do not know if it will match. EG: /** * updateProduct */ function updateProduct($ProductName, $field, $value){ $q = "UPDATE ".TBL_PRODUCTS." SET ".$field." = '".mysql_real_escape_string($value)."' WHERE ProductName = '".mysql_real_escape_string($ProductName)."'"; return $this->query($q); } Do I escape $field? mysql_real_escape_string($field)?
You can only escape data, not field or table (or database) names. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.db (#47329) next »