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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:09:17+00:00 2026-05-27T04:09:17+00:00

I have posted about this before but never in this regard so please take

  • 0

I have posted about this before but never in this regard so please take a look:

I was told one way to do sql injections was to use 1=1 where someone can see all entries that don’t belong to them.

But lets say i structure my query so that it also selects the user_id of the current user, would that work:

  $userid = Current users stored id in database;
  $postid = mysql_real_escape_string($_GET['id']);

And now lets assume that i enter: domain.com/page.php?id='' OR '1'='1'

Select article_name from table where user_id=$userid and post_id=$postid

Will the query still return everything or will it not since i have added the User_id barrier?

  • 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-05-27T04:09:17+00:00Added an answer on May 27, 2026 at 4:09 am

    mysql_real_escape_string() is for sanitizing strings only. It does NOT protect from SQL injection in integers that are not wrapped in quotes, so your observation is correct: What is shown above is indeed not safe despite mysql_real_escape_string().

    You need to either wrap your values in quotes:

    Select article_name from table where user_id='$userid' and post_id='$postid'
    

    or make sure that $userid and $postid are integers before running the query.

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

Sidebar

Related Questions

I've posted about this before but have been struggling to come up with a
This post is similar to one I have posted before about a dropdown filtering
I have already posted another question about this, but no one seemed to know
I have already posted a question about this, but the situation has changed sufficiently
This sounds like a problem many others have posted about, but there's a nuance
I posted a thread about this earlier and have made some progress but now
Possible Duplicate: Can someone Explain this jQuery code? I have posted this before, but
I've posted about this problem before, but I still haven't found a solution so
i have previously posted about triggering a dialog box before confirming a submit. But,
I posted about this before to a degree, but after a few days of

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.