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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:34:23+00:00 2026-06-04T14:34:23+00:00

I have used mysql_real_escape_string to enter info into the database but when I return

  • 0

I have used mysql_real_escape_string to enter info into the database but when I return the info in a query I get \\\' in the text. I have made it so that the insert query does not stop at the ' in a sentance anymore when saving as it used to. It used to stop saving he title of an article halfway through if it contained an apostrophe. That has been fixed but now I get \\\' where there is an apostrophe.

Example: Microsoft\\\'s $15 Windows 8 upgrade offer to run from June 2nd to January 31st, will include free workshops

My query code to return a list from the database looks like this: (Note that this is an excerpt so does not contain the closing of this loop)

<?php

    $q2 = "SELECT * FROM ReadLater WHERE Folder_ID = 0 AND User_ID = $loggedInUser->user_id ORDER BY dt_added DESC";
    $r2 = mysql_query($q2);

    echo "<div id='folderstitleright'>Unread</div>";

    if(mysql_num_rows($r2)>0)
        {
        echo "<ul id='foldersarticlelist'>";
        $sr2=1;
        while($row = mysql_fetch_assoc($r2))

            {

            echo "
               <li class='box'>

etc

Any idea how to stop this? I have tested to see if magic quotes are on and they are but with the web host I have no way of turning them (that i have found, there may well be a really complicated way but I haven’t found it yet) of and they also say they ignore php flags in the .htaccess file.

I have tried to do a preg_replace of \\\' to ' but have so far been unsuccessful, from what I have tried of that it breaks the query entirely but I may well be executing it wrong or have it placed in the wrong place in the code above.

  • 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-04T14:34:25+00:00Added an answer on June 4, 2026 at 2:34 pm

    Don’t use preg_replace with this, just use str_replace.

    $text = str_replace("\\\\\\", "'", $text);
    // Use 6 slashes as '\\' is really '\' because '\-' is an escape sequence.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a column in my SQL-2005 database that used to be a varchar(max)
The following SQL query: INSERT INTO `database`.`table` (`param1`, `param2`) VALUES ( 'Новости Томска –
I am very used to using MySQL and mysql_real_escape_string(), but I have been given
I'm using mysql_real_escape_string to cleanse data that's used in insert and update queries (postal
I have used full text search mysql. My code is select * from uh_property
I am new to MySQL, but I have used Oracle for some time. I
I need to used dynamic order query in mysql and i have successfully achieved
mysql_real_escape_string is used for SQL statements. Is it enough for database security alone? For
I have a record edit link that GETs a 7 character alphanumeric text string
Historically, I've always used mysql_real_escape_string() for all input derived from users that ends up

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.