0

If someone is injecting MySQL statements to my PHP-based app. I use MySQLi real escape strings, however the attacker simply injects SQL statement. Let's assume:

http://example.com/?id=1

The attack simply injects a statement: http://example.com/?id=1 LIMIT 10

And, even after escaping the strings, the code is executed as follows.

SELECT * FROM ex WHERE id = 1 LIMIT 10
Areeb
  • 554
  • 4
  • 13

1 Answers1

0

MySQLi real escape strings does not prevent SQL injection, It simply helps prepare query string data and escape sensitive characters. You need to use Prepared Statements.

Nick
  • 1,783
  • 1
  • 15
  • 18
  • Is there any way to prevent this? I am not using prepared statements, any idea to fix this real fast? – Areeb Feb 24 '16 at 04:11
  • @Areeb start using prepared statements. For the particular instance you describe, you know you need a number. Use `is_numeric`. –  Feb 24 '16 at 04:17