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 7995379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:23:59+00:00 2026-06-04T14:23:59+00:00

I was trying to demonstrate the need for prepared statements in PHP, but I

  • 0

I was trying to demonstrate the need for prepared statements in PHP, but I came into a bit of a problem because PHP does some conveniently strange things with strings passed in through forms.

The statement I’m trying to “break” is a simple:

SELECT username FROM users WHERE username = '$username' AND password = '$password'

But doing something like passing in X' or TRUE;-- for the password doesn’t actually work because PHP automatically escapes the single-quote and turns the statement into:

SELECT username FROM users WHERE username = '$username' AND password = 'X\' or TRUE;--'

And the password equality remains intact because of the escaped single-quote. Is this statement considered safe? How can it be broken, if not?

  • 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-04T14:24:00+00:00Added an answer on June 4, 2026 at 2:24 pm

    It sounds like you have magic quotes turned on. I would definitely not consider that statement safe, as if you were to move it to a server running PHP 5.4, it would be completely vulnerable. Magic quotes has been a deprecated feature for a long time, and it can mess up other parts of the application, so don’t rely on it.

    To demonstrate, just set magic_quotes_gpc = Off in php.ini.

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

Sidebar

Related Questions

The following markup is exaggerated to demonstrate the problem. I'm trying to capture the
Trying to use GnuPG with Delphi (Win32). I need to sign some file with
I need some help with recursion. I'm trying do a binary tree in C#,
this the code in which i am trying to demonstrate nested lock problem, import
I'm trying to deserialize some XML from a web service into C# POCOs. I've
I'm trying to write an application (winforms) that can demonstrate how two oscillating colors
Trying to parse an HTML document and extract some elements (any links to text
I'm trying to demonstrate the consequences of an XSS flaw to a client and
I need to distribute a value based on some weights. For example, if my
It is a simple but common task required when trying to fix a colormap

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.