MYSQL - What all do I need to escape when sending a (My)SQL query?
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
When you execute a SQL query, you have to clean your 'strings' or users can execute malicious SQL on your website.
I usually just have a function escape_string(blah), which:
- Replaces escapes () with double escapes (\).
- Replaces single quotes (') with an escaped single quote (\').
Is this adequate? Is there a hole in my code? Speedy library to reliably do this for me?
I'd like to see graceful solutions in:
- Perl
- Java
- PHP
This question and answers originated from www.stackoverflow.com
Question by superjoe30 (8/5/2008 6:45:46 PM)
Answer |
For maximum security, performance, and correctness use prepared statements. Here's how to do this with lots of examples in different languages, including PHP:
http://efreedom.com/Question/1-1973/what-is-the-best-way-to-avoid-sql-injection-attacks
Answer by Mark Harrison
Find More Answers