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
https://forums.phpfreaks.com/topic/204969-apostrophe-problem/
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
https://forums.phpfreaks.com/topic/204969-apostrophe-problem/#findComment-1073071
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.