Re: Using mysql_real_escape_string without connecting to mysql
| From: | Jim Lucas | Date: | Thu, 24 Jan 2008 23:17:35 +0000 |
| Subject: | Re: Using mysql_real_escape_string without connecting to mysql | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-268050@lists.php.net to get a copy of this message | ||
Richard Lynch wrote:
On Thu, January 24, 2008 12:03 pm, Dotan Cohen wrote:That should be considered part of the DRY method. But spanning page requests. I cannot see any reason why you shouldn't be doing this before you insert this information into your DB. Doing it once on your insert, instead of every single page request would seen to me a much better use of resources. If you are needing to have the tags in the DB, what I would do is have add second column in your DB. One that contains the clean version and one that contains the marked up version. Then you are not doing so much work on each page load, and you are able to retain the marked up version for editing ( i assume )On 24/01/2008, Richard Lynch <ceo@l-i-e.com> wrote:The strip_tags should probably have been done before it ever went into the database, as part of INPUT FILTERING rather than escaping output...It is NOT safe from, say, XSS attack if $evilString contains an XSS snippet and you re-display it on your site. In other words, you should still filter the INPUT somewhere; But you are escaping the output to MySQL so that it is not going to execute arbitrary SQL on your DB server.After I pull the info out of the database, before it goes to the webbrowser, it goes through this: function clean_html ($dirty) { $dirty=strip_tags($dirty);
-- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare$clean=htmlentities($dirty); return $clean; } Dotan Cohen http://what-is-what.com http://gibberish.co.il ×-ב-×’-ד-×”-ו-×–-×—-ט-×™-ך-×›-ל-×-מ-ן-×-ס-×¢-×£-פ-×¥-צ-×§-ר-ש-תA: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?