Join Date: Nov 2006 Location: Inside an igloo, Canada
Posts: 313
| SQL Injection Attacks question. Anybody? I am currently working on a PHP/mySQL based website and wanted to get some feedback if I'm doing it correctly.
There are a few sections that use GET to pass info, including category id's and names to another page, then its searched it in the database.
I am using: Code: mysql_real_escape_string($categoryid); Is this enough to prevent injection attacks?
I have tried the classic OR 1=1 with: Code: example sql:
Select * FROM sometable id = ".$categoryid
result would be:
Select * FROM sometable id = 5 OR 1=1 This failed, and returned all rows
By adding single quotes around the inserted variable: Code: Select * FROM sometable id = '".$categoryid."'" It works, even though I'm not used to putting quotes around numbers.
Has anyone used mysql_real_escape_string in the past and is it enough? || AMD Athlon64 3800+ Venice | Asus A8N5X s939 | OCZ Premier PC3200 Du-Ch 1GB | Sapphire X1600Pro 512MB PCI-e | 1xWD 80Gb & 1xWD 250Gb Sata(s) | Antec SLK3800B Case | Enermax NoiseTaker 485W ||
Last edited by pc_guy; February 7th, 2007 at 11:12.
|