phpstripslashes

Strip slashes from database request correctly


I have message stored in my database containing a slash: e.g. don\'t

To present the message I use this procedure. The thing is the backslash is still displayed. How can I get rid of it. I have tried many things, and read several postings here, but can't get it to work. Anyone here to help me and tell me what is the best way..

            $msg2 = html_entity_decode($row3[comment]);
            echo stripslashes(nl2br($msg2));

Solution

  • When storing them in the database, you should store them as mysql_real_escape_string($phpString).

    Why do you use html_entity_decode for this? Just stripslashes should be sufficient here..