We help IT Professionals succeed at work.

Php inserting quotes

Toube
Toube asked
on
252 Views
Last Modified: 2008-02-01
Hi,

i have a problem with my message board:
When a users posts a new message that contain quotes "", the quotes will be displayed the following way \"\" any idea why this is happening.. I have the following lines for inserting into database:

$new_post = addslashes(htmlentities($post, ENT_QUOTES));
$new_post = preg_replace('/(http:\/\/[^ ]+\.[^ \r\n]+)/ie', "'<span class=\"member_links_underline_black\"><a href=\"$1\" target=\"_blank\">'.breakWords('$1', 65).'</a></span>'", $new_post);

And when outputting the post:

$post = addslashes(htmlentities($row['Post'], ENT_QUOTES));
echo $post;

Thanks,
-T
Comment
Watch Question

Commented:
Try changing this line:
$post = addslashes(htmlentities($row['Post'], ENT_QUOTES));

to
$post = htmlentities($row['Post'], ENT_QUOTES);

Commented:
By the looks of it, you convert the text with htmlentities() before you put the text in the DB right?

If so, you shouldn't call it when echoing $post, so you can probaly even change it in:

$post = $row['Post'];

Author

Commented:
Hi Terref, tried it still displays those backslashes..

-T

Author

Commented:
True, the htmlentities from echoing the post.. problem still there.

-T

Commented:
$post = stripslashes(htmlentities($row['Post'], ENT_QUOTES));
echo $post;
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Yes, that did the trick Terref, thanks again great work :)

-T

Commented:
Thanks, you're welcome :)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.