createPost adds slashes after ' --> \'

Started by Biology Forums, June 18, 2018, 09:28:58 PM

Previous topic - Next topic

Biology Forums

I'm using createPost in a test SMF 2 website and every time a topic with apostrophes is created, SMF doesn't convert it into an html code, but rather adds slashes '\.

I think in SMF 1 it's change them to '

How can I prevent slashes being added?

TehCraw

Investigation would require installing a 2.x copy, which I'm not feeling right now, so can't give an exact answer as to why. But I'd suggest running your input through htmlspecialchars($input, ENT_QUOTES);

That should fix it.
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

Biology Forums

Thank you, but it didn't work ... Here's my code

$subject = mysql_escape_string( $subject );

$subject = htmlspecialchars( $subject, ENT_QUOTES );

$subject = un_htmlspecialchars($subject);

$subject = strip_tags($subject);

$subject = strtr(htmlspecialchars($subject), array("\r" => '', "\n" => '', "\t" => ''));

Kindred

Yes, I believe that the slash is correct. That's how it gets stored 8m the databae, iirc
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

vbgamer45

i would skip  mysql_escape_string as long as you are using the createpost for the subject it should work ok.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Biology Forums

Quote from: vbgamer45 on June 18, 2018, 10:41:44 PM
i would skip  mysql_escape_string as long as you are using the createpost for the subject it should work ok.

That did it.

Ty

Advertisement: