Re: Struggling with MySQL query
| From: | Ashley Sheridan | Date: | Tue, 09 Aug 2011 20:19:49 +0000 |
| Subject: | Re: Struggling with MySQL query | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314454@lists.php.net to get a copy of this message | ||
David Green <simpill@gmail.com> wrote:
>Thank you all for the various suggestions.
>
>It now works with this:
>
>$find = strip_tags($find);
>$find = trim($find);
>
>$data = mysql_query("SELECT * FROM news_items WHERE headline LIKE
>'%$find%'");
>
>Another "newb" question: does strip_tags() help at all in preventing
>SQL
>injection attacks?
>
>Kind regards
>David
strip_tags() doesn't prevent against sql injection. At best, it can protect slightly against
xss attacks. Use mysql_real_escape_string() for sql injection.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.