TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,911
  • Total Topics: 21,307
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 441
  • Total: 441

V0.9.8 - Apostrophes in PHP based Articles

Started by SniffTheGlove, May 26, 2010, 07:39:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SniffTheGlove

I have tried to search for an answer but the Search facility has been temporary disabled.

I am still using v0.9.8 (waiting for SMF to go gold and then for TP to be SMF2 Compliant)

I have created an Article using ADD PHP.

I am pulling out a text field of a MySQL DB and storing it as a variable, the data is stored in the DB fields with apostrophe's encoded as &# 039; (Space is there just for this post but not there in the actual code) using htmlentites.

Now one of the lines of php code in the article searches the variable for the encoded apostrophe and then puts a backslahes before it like \&# 039; (Again ignore the space)

I need the apostrophes like this as after being processed the variable is then sent to a javascript script where the \ is removed and the variable is displayed by the script.

I have to have the apostrophes re-encoded like this else the javascript see's it as a text delimiter.

Now the actual problem is that TP is running the article fine after I press SAVE however if I go and re-open the article for editing the code the code shown in the article body text box &# 039; is no longer present as it has been converted to an actual apostrophe and then further SAVE just breaks the code.

How can I get TP to keep the actual code correct with &# 039; as it should be when going to redit the code

Thaanks

lurkalot

#1
If I understand you correctly which is pretty rare for a  :idiot2: like me.

Have you tried turning off the WYSIWYG editor? 

Admin / Tinyportal / Settings / Use the WYSIWYG editor?  Yes/No.

SniffTheGlove

There is no editor running, the Add PHP Article page just has..

Use PHP in Article ticked
Title Text Box
Body Text Box
Show on front page
Category


IchBin

I'm sure part of the reason that TP parses special characters into htmlentities is for security. You'll probably haven't to do some decoding of your own if you want to change it. I'd take a look at the decode funciton.
htmlspecialchars_decode()

This website is proudly hosted on Crocweb Cloud Website Hosting.