note 99115 added to function.filter-input
| From: | travismowens at gmail dot com | Date: | Wed, 28 Jul 2010 16:21:32 +0000 |
| Subject: | note 99115 added to function.filter-input | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171189@lists.php.net to get a copy of this message | ||
I wouldn't recommend people use this function to store their data in a database. It's
best not to encode data when storing it, it's better to store it raw and convert in upon the
time of need.
One main reason for this is because if you have a short CHAR(16) field and the text contains encoded
characters (quotes, ampersand) you can easily take a 12 character entry which obviously fits, but
because of encoding it no longer fits.
Also, while not as common, if you need to use this data in another place, such as a non webpage
(perhaps in a desktop app, or to a cell phone SMS or to a pager) the HTML encoded data will appear
raw, and now you have to decode the data.
In summary, the best way to architect your system, is to store data as raw, and encode it only the
moment you need to. So this means in your PHP upon doing a SQL query, instead of merely doing an
echo $row['title'] you need to run htmlentities() on your echos, or better yet, an
abstract function.
----
Server IP: 64.71.164.2
Probable Submitter: 96.238.155.200
----
Manual Page -- http://www.php.net/manual/en/function.filter-input.php
Edit -- https://master.php.net/note/edit/99115
Del: integrated -- https://master.php.net/note/delete/99115/integrated
Del: useless -- https://master.php.net/note/delete/99115/useless
Del: bad code -- https://master.php.net/note/delete/99115/bad+code
Del: spam -- https://master.php.net/note/delete/99115/spam
Del: non-english -- https://master.php.net/note/delete/99115/non-english
Del: in docs -- https://master.php.net/note/delete/99115/in+docs
Del: other reasons-- https://master.php.net/note/delete/99115
Reject -- https://master.php.net/note/reject/99115
Search -- https://master.php.net/manage/user-notes.php