How can I prevent SQL injection in PHP?
42428 Oct 2020
If user input is inserted without modification into an SQL query, then the application becomes vulnerable to SQL injection, like in the following example:
$unsafe_variable = $_POST["user_input"];
mysql_query("INSERT INTO `table` (`column`) VALUES ("$unsafe_variable")");
That"s because the user can input something like value"); DROP TABLE table;--, and the query becomes:
INSERT INTO `table` (`column`) VALUES("value"); DROP TABLE table;--")
What can be done to prevent this from happening?
0 likes
Top related questions
Related queries
Latest questions
रूस ने यूक्रेन पर अब तक का सबसे बड़ा हवाई हमला किया
29 Jun 2025 2
भगवान जगन्नाथ मुस्लिम भक्त सलाबेगा की प्रेरणादायक कहानी रथ यात्रा में गूँज, भक्ति का एक अनूठा उदाहरण
28 Jun 2025 1
अलकनंदा नदी में बस गिरी, 2 की मौत, 10 लापता
26 Jun 2025 1
ईरान के फोर्डो परमाणु संयंत्र पर अमेरिकी हमले के बाद सैटेलाइट तस्वीरों का विश्लेषण, चैटजीपीटी ने खोले राज
24 Jun 2025 1
What is Angle Bracket in HTML?
23 Jun 2025 1
NIA की बड़ी कार्रवाई: पहलगाम हमले में दो गिरफ्तार
22 Jun 2025 1