Jump to content

Apostrophe problem


billy_111

Recommended Posts

Hey,

 

I have the following update statement:

 

    public function updateReviews(){



        if(is_numeric($_POST['ID'])){



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

            $body = str_replace(''', '', $body);



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

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

            $admission = mysql_real_escape_string(htmlentities($_POST['admission']));

            

            $sql = "UPDATE tbl_reviews SET

                    catID = '".mysql_real_escape_string($_POST['catID'])."',

                    title = '".mysql_real_escape_string($_POST['title'])."',

                    body = '$body',

                    address = '$address',

                    postcode = '".mysql_real_escape_string($_POST['postcode'])."',

                    tel = '".mysql_real_escape_string($_POST['tel'])."',

                    website = '".mysql_real_escape_string($_POST['website'])."',

                    admission = '$admission',

                    other = '$other',

                    date_added = now()

                    WHERE ID = ".$_POST['ID']."";

            print_r(mysql_error());

            $result = mysql_query($sql) or die(mysql_error());

            return $result;

        }else{

            die('ID needs to be numeric');

        }

    } 

 

When i run this this line does not really work:

 

$body = str_replace(''', '', $body);

 

If you look at this page:

 

http://freemanholland.com/babies/reviews/?ID=9

 

And look at the "Smithills Country Park" review, you will see that where there should be an apostrophe it shows the word like this:

 

you\\\'re

 

Any ideas why this is?

 

Thanks

 

 

 

Link to comment
Share on other sites

What exactly are you trying to do?

 

The reason you're getting \\\' is because you're escaping it, and I assume that it has already been escaped, so it's being double-escaped.

 

Also, this line needs to be this way, if that's what you want:

$body = str_replace("'", '', $body);

or

$body = str_replace('\'', '', $body);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.