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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:33:49+00:00 2026-06-09T06:33:49+00:00

I use mysql_real_escape_string on stuff that gets put in my database, so something like

  • 0

I use mysql_real_escape_string on stuff that gets put in my database, so something like Bob's Shop would turn into Bob\'s Shop. And, for example, if I try to select all the entries that contain Bob\'s, my select statement looks like:

SELECT * FROM tbl WHERE name LIKE '%Bob\\\'s%' 

and for whatever reason, it doesn’t work, even though it makes complete sense that it would work.

  • 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-09T06:33:51+00:00Added an answer on June 9, 2026 at 6:33 am

    I fixed it (thanks to Michael for showing me how). I’m posting what I did in case someone else has this problem.

    Never figured out how to properly put escape characters in a LIKE, but the problem was that I had magic quotes turned on, so whenever I used mysql_real_escape_string, it added additional escape characters so that instead of being stored as Bob’s, it was stored as Bob\’s. This is the documentation to disable magic quotes: http://www.php.net/manual/en/security.magicquotes.disabling.php
    For me, putting php_flag magic_quotes_gpc Off or php_value magic_quotes_gpc Off in the .htaccess didn’t work because I’m using purchased hosting and the host doesn’t allow settings like that or something. So instead I put magic_quotes_gpc = Off in a file called php.ini and put it in every directory that I needed it.

    Since I already had a lot of rows in my MySQL database that contained the extra backslashes, I needed to get rid of them when I turned off magic quotes. You can do this easily by issuing a query like this: UPDATE tbl SET col=REPLACE(col,'\\\'','\'') WHERE col LIKE '%\'%' Replace tbl with your table name and col with any column you’re working with. If there’s other escape characters you need to fix, just change the REPLACE and LIKE to reflect that. There’s probably better code to do all columns and all escape characters in one swoop, but for my purposes I didn’t need that.

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

Sidebar

Related Questions

When i add something to my mysql db, i use mysql_real_escape_string(), then put it
I currently use mysql_real_escape_string to escape a variable when querying the database to prevent
to sanitize user input we usually use mysql_real_escape_string, but for example if i want
I normally just use mysql_real_escape_string on every variable before inserting to my database, so
I want to allow user to put his data into text filed . that
I use mysql_real_escape_string() before interting information in the database, but when I want to
Kohana mentions they use mysql_real_escape_string to sanitize database inputs in their documentation. However, while
According to php.net I should use mysql_real_escape_string() and turn off magic quotes , because
When should i use mysql_real_escape_string? Is it only when i'm inserting rows into a
so i use mysql_real_escape_string to sanitize some user input before entering it into the

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.