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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:46:04+00:00 2026-05-24T22:46:04+00:00

I read in some tutorials/example that this function will save in database the <a

  • 0

I read in some tutorials/example that this function will save in database the

<a href="http://foo.com">foo</a>

as

<a href=\"http://foo.com\">foo</a>

In my case (i have magic_quotes off as many people suggests),

$text = mysql_real_escape_string($_POST['text']);
$sql="INSERT INTO test (text) VALUES ('$text')";

it is saved as <a href="http://foo.com">foo</a> in the DB which I see through phpMyAdmin.

I guess this is because of magic_quotes because when I had them on, it was saved as <a href=\"http://foo.com\">foo</a>.

With magic_quotes turned off and my example above, am I safe against SQL injections?

  • 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-24T22:46:04+00:00Added an answer on May 24, 2026 at 10:46 pm

    The point of escaping is to make ambiguous syntax unambiguous.

    INSERT INTO test (text) VALUES ("<a href="http://foo.com">foo</a>")
    

    This is ambiguous/wrong because the database cannot tell whether the " inside the " are to be taken literally or whether they signal the end of the string you want to put in the database. Notice the screwed up syntax highlighting here on SO as well. mysql_real_escape_string escapes that to:

    INSERT INTO test (text) VALUES ("<a href=\"http://foo.com\">foo</a>")
    

    This is now unambiguous, the inner " do not signal the end of the string.

    That’s the only thing escaping does, it does not permanently insert backslashes into the string.

    Please read The Great Escapism (Or: What You Need To Know To Work With Text Within Text).

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

Sidebar

Related Questions

I'm trying to read some OpenGL tutorials on the net. the problem is that
I read some tutorials that say that a simple bean should be defined with
I read some tutorials concerning Makefiles but for me it is still unclear for
I have just switched from svn to mercurial and have read some tutorials about
according to some tutorials i read a while back, the const declaration makes a
I've read much of the MySQL Cluster docs and some tutorials yet I still
Is there any book or links that I can read some tutorial about the
I've made some unit tests (in test class). The tutorial I've read said that
I read some properties from an xml file, amongst which is a string that
I'm a bit confused by a few tutorials that I read about the ListView.

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.