Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8593089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:54:28+00:00 2026-06-11T23:54:28+00:00

I have read various articles suggesting to use Prepared statements in SQL queries, but

  • 0

I have read various articles suggesting to use Prepared statements in SQL queries, but since mysql_ lib does not allow executing 2 queries in one statement is it worth to use them if I need to fire a query only once in the execution of the page and it some cases the mysql_query also seems to ignore invalid post data (like 'ADMIN' OR 1--)

$username = $_POST['username'];
$password = $_POST['password'];

 mysql_query("SELECT * FROM users WHERE username=$username AND password=$password");

//processing

Now, If anyone passes “username” as

'ADMIN' OR 1--

The above query dosent fetch the “Admin” row! Is this a feature of mysql_query that ignores the comment after '1' / Special chars. How would a SQL Injection happen in this case, running MYSQL 5.5 and PHP 5.3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:54:30+00:00Added an answer on June 11, 2026 at 11:54 pm

    Perhaps 'ADMIN' OR 1-- doesn’t work, but 'ADMIN' OR 'x' = 'y' certainly would, since it would result in this SQL query:

    SELECT *
      FROM users
     WHERE username = 'ADMIN'                    -- true
        OR 'x' = 'y' AND password = 'whatever'   -- false, but who cares?
    ;
    

    The general lesson: coding for security is hard, because we’re not used to thinking in terms of hostile agents actively seeking to disrupt our code. SQL injection is a solved problem, and the solution is parameterized queries, so you should use that rather than trying to roll your own attempted solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read various articles about passing variables around using RMI. Some of them
I've read through the various posts on SO about this, but have still not
I have read few articles about table partioning but still I am bit confused
I've read various articles on the web, but they seem rather scattered on this
I have read various articles about the modal state that is used in the
I read have most if not all of the various articles on adding MVC
I have tried googling and read through https://help.github.com/en/articles/connecting-to-github-with-ssh and various, various guides. I am
All - Have read various articles on the new keyword and when it should
I have read various posts in stackoverflow and I am trying to figure out
I have read in various places that having variables with global scope, i.e. a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.