Ask about SQL injection. Hello everyone & nbsp; I made a website a few days ago & nbsp; considering that I didn't do SQL anti-injection & nbsp; I have read some case columns & nbsp; I used them on my own website & nbsp; but they didn't respond & nbsp; now I 'd like to ask & nbsp; how can I build SQL code to be injected? The main statement is this & lt ;? Phpinclude & nb ask about SQL injection
Hello, everyone, I made a website a few days ago. considering that I didn't do SQL anti-injection, I read some cases and used them on my own website but didn't respond. now, please ask me how to write SQL code like this. can be injected?
This is the main statement.
Include "../admin/connss. php ";
$ Id = $ _ GET [id];
$ SQL = mysql_query ("select * from news where id = '$ ID '");
$ Row = mysql_fetch_array ($ SQL );
?>
I don't think it's okay to filter the data. it should be injected. but I tried some methods and it's okay to ask.
Thank you.
------ Solution --------------------
Both addslashes and mysql_real_escape_string can escape fields to prevent injection.
------ Solution --------------------
-- Your program design looks like this:
-- $ Id = "100"
Select... from... where ID = '201312 ';
-- The SQL injection result is as follows:
-- $ Id = "100 'or '1' = '1"
Select... from... where ID = '20180101' or '1' = '1'