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

  • Home
  • SEARCH
  • 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 9244469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:02:26+00:00 2026-06-18T09:02:26+00:00

So I know the basics of a SQL injection attack, with entries that are

  • 0

So I know the basics of a SQL injection attack, with entries that are not sanitized. So

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

(Note that $password is hashed) would be defeated with $username=x' or 1=1; --

A friend said that if you throw a \n character into your source code, then you can’t comment the rest of the query out. So if you have

Select id
from users
where username='$username'
and password='$password' 

in php, and then submit it to the query, then even if they tried to comment out the username, it would error because the and password='$password' would still try and be executed.

I tried it, and he seems to be correct. So, my question is, while you should still sanitize your database inputs, does this prevent an attack like this, or is there a way to bypass it still?

I don’t know if it matters, but I’m talking specifically about mysql here.

  • 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-18T09:02:28+00:00Added an answer on June 18, 2026 at 9:02 am

    I toyed around a bit with this, but I don’t see this method of using newlines helping at all. Maybe there’s some differences between different versions of mysql clients, but running PHP with MySQL-ND adding the newlines doesn’t seem to help against sending the username x' OR 1=1 OR ', this doesn’t rely on the -- commenting at all, which effectively defeats the whole purpose of the newline.

    There may be easier and other ways around it as well, but it seems quite easily defeated at least. I would never trust a “clever solution” like this.

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

Sidebar

Related Questions

I am not very familiar with SQL Server but I know the basics. I
I want to know about Virtualization in detail. But start from basics, like what
I've heard from some that LINQ to SQL is good for lightweight apps. But
I have an sql query: DELETE **x** FROM $table **x** JOIN ( SELECT vendors
I want to know the basics of dynamic sql especially in PostgreSQL. I was
Note that I'm a complete SQL noob and in the process of learning. Based
I only know basic SQL but the project that I am working on uses
I know basics of UML and java's OO interpretations using class diagrams. But after
I have a problem with operators. Generally I know basics of using operators. But
i know the basics of recursion but in the given code i m facing

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.