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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:39:16+00:00 2026-06-15T05:39:16+00:00

I am trying to protect against sql injections by using mysql_real_escape_string before inserting data

  • 0

I am trying to protect against sql injections by using mysql_real_escape_string before inserting data to the database:

$data=mysql_real_escape_string($_POST['data']);

Now, the data is stored as such:

That\\\'s an apostrophe.\r\n\r\nThis new line isn\\\'t displaying properly!

So, I am trying to get it to display correctly inside of a textarea after pulling it back out of mysql:

$data = nl2br($data);

For whatever reason, this does NOTHING. I’ve even tried str_replace to replace the \r\n's with a <br>, but then the <br> just displays within the textarea.

How do I get what’s in my mysql to display as:

That's an apostrophe.

This new line isn't displaying properly!
  • 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-15T05:39:17+00:00Added an answer on June 15, 2026 at 5:39 am

    you probably have magic_quotes turned on,
    check it with
    echo get_magic_quotes_gpc()
    or else you will double quote

    "Sets the magic_quotes state for GPC (Get/Post/Cookie) operations. When magic_quotes are on, all ‘ (single-quote), " (double quote), \ (backslash) and NUL’s are escaped with a backslash automatically. "

    by the way, it’s not a good ideia to use magic_quotes, try using one of this classes.

    PDO https://www.php.net/manual/en/book.pdo.php
    or mysqli https://www.php.net/manual/en/book.mysqli.php

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

Sidebar

Related Questions

I'm trying to learn more about MySQL and how to protect against SQL injections
I'm trying to protect my .NET web site against CSRF attacks using a hidden
I'm aware of how to protect against SQL injections & stuff & validating user
I have create a LINQ-to-SQL project in Visual Studio 2010 using Dynamic Data. In
I'm trying to export a schema in an oracle 10 database using the EXP
I am editing a search form and trying to protect against special characters in
I'm trying to setup my project so that I can use querydsl-sql against a
Okay, I'm stumped. I'm fiddling with some project settings, trying to start linking against
I'm trying to password protect a directory on a server that's running IIS. I've
I am trying to use Dotfuscator (CE) to help protect our ASP.NET MVC .ddl.

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.