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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:04:13+00:00 2026-05-19T17:04:13+00:00

According to php.net I should use mysql_real_escape_string() and turn off magic quotes , because

  • 0

According to php.net I should use mysql_real_escape_string() and turn off magic quotes, because it’s deprecated.

So I turned it off and I used mysql_real_escape_string(), but is it enough to use it just like in the following code?

$value = "It's Time!";
$escaped_value = mysql_real_escape_string($value);

mysql_query("INSERT INTO table (column, column2) VALUES ('{$escaped_value}', "0")");

When I check the data in the database it looks the same way as in $value so "It's Time" and not "It\'s Time". Is this normal? Shouldn’t this add a slash before the quotes?

  • 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-19T17:04:13+00:00Added an answer on May 19, 2026 at 5:04 pm

    That’s the correct behaviour, and it works! Quotes are escaped in the query, not in the database. \’ in the SQL query must be converted to ‘ inside the database.

    You escape strings, so the SQL query doesn’t get messed up and lets input quotes to the database without the SQL query interpreting them as control characters.

    Your escaped query would be:

    mysql_query("INSERT INTO table (column, column2) VALUES ('It\'s time', "0")");
    

    Your database data should be “It’s time”.

    If it weren’t escaped it would be:

    mysql_query("INSERT INTO table (column, column2) VALUES ('It's time', "0")");
    

    It will spit out an error regarding “s time'” (because it will only interpret until the next quote character, and will only see ‘It’.) And “It’s time!” is just an inoffensive string, but lots of attacks could derive from that if you don’t escape your characters.

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

Sidebar

Related Questions

I use PHP 5.3 on Debian and according to php -m 'Phar' is loaded.
According to the PHP manual , in order to make code more portable, they
According to what I have found so far, I can use the following code:
According to this article Silverlight 2 Beta 2 supports the DataContractJsonSerializer object. But, when
I am trying to install PEAR for use with PHP. As i read on
According to articles like: http://www.oreillynet.com/onjava/blog/2007/06/easy_ajax_with_struts_2.html and http://www.firstpartners.net/kb/index.php/Easy_Ajax_using_Struts_2 it should be easy (out of the
the specific example i am referring to is this site http://www.iamextreme.net/category.php?CategoryId=1&SubCategoryId=0&SortBy=name notice the sort
According to PHP's official documentation the imagepng() function has the following signature: bool imagepng
According to you, what is the best solution in PHP to ensure the course
According to this discussion , the iphone agreement says that it doesn't allow loading

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.