Question 66Asked in Bihar STET 2024 Paper II Computer Science, 12 Jun 2024, Shift 1 (10:00 AM)

How can you prevent SQL injection vulnerabilities in your PHP code?आप अपने PHP कोड में SQL इंजेक्शन कमजोरियों को कैसे रोक सकते हैं?

आप अपने PHP कोड में SQL इंजेक्शन कमजोरियों को कैसे रोक सकते हैं?
  1. ABy using short and simple SQL queriesलघु और सरल SQL क्वेरीज़ का उपयोग करके
  2. BBy not using user input in queriesक्वेरीज़ में उपयोगकर्ता इनपुट का उपयोग न करके
  3. CBy removing error handling from the codeकोड से त्रुटि हैंडलिंग को हटाकर
  4. DBy disabling database privilegesडेटाबेस विशेषाधिकारों को अक्षम करके
Show answerHide answer

Correct answer: (B) By not using user input in queriesक्वेरीज़ में उपयोगकर्ता इनपुट का उपयोग न करके

Explanation

SQL injection happens when raw user input is joined into a query string. The fix is not to put user input directly into queries: use prepared statements or parameterised queries (PDO or mysqli) so input is treated as data, not code.SQL injection तब होता है जब कच्चे उपयोगकर्ता इनपुट को query स्ट्रिंग में जोड़ दिया जाता है। समाधान यह है कि उपयोगकर्ता इनपुट को सीधे queries में न रखें: prepared statements या parameterised queries (PDO या mysqli) का उपयोग करें ताकि इनपुट डेटा माना जाए, कोड नहीं।

From Bihar STET 2024 Paper II Computer Science PYQ, 12 Jun 2024, Shift 1 (10:00 AM)

This is question 66 of Bihar STET 2024 Paper II Computer Science PYQ, 12 Jun 2024, Shift 1 (10:00 AM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.