Solved

Where is this strange code coming from in my php/mysql app and how do I get rid of it?

Posted on 2012-03-19
9
446 Views
Last Modified: 2012-03-20
Last week, Thursday to be exact, the autogen php/mysql web form we have has a textarea field where we use tinyMCE to allow client to input and format their text. Suddenly on Thursday the text would not appear in the form, along with the border that surrounds the textarea data in display mode, but when we went to the edit screen where the tinyMCE field is, we could see the text. I came in today and looked at the db and see all this odd code in the db [see below].  Think the user copied and pasted some word doc into the field, but now now matter what I get that odd code.

I have overwritten the code with straight, clean text, load the page it work, but then it eventually reverts to this odd code-- and at some point you refresh your browser and no longer see any text from the php form. When I look in the db again, all this code[see below]is back in the field.

I been surfing/researching and various suggestions include updating tinyMCE, which I did, but same things happens.

Does anyone have any idea what I should do, what part of the code to attack, is it the db or the tinyMCE? All help is much appreciated. [Note: app has been running successfully for about 2 years.]

Example of Code:
<p><!--[if gte mso 9]><xml> <o:OfficeDocumentSettings> <o:AllowPNG />
> </o:OfficeDocumentSettings> </xml><![endif]--><!--[if gte mso 9]><xml>
> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom>
> <w:TrackMoves /> <w:TrackFormatting /> <w:PunctuationKerning />
> <w:ValidateAgainstSchemas />
> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
> <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
> <w:DoNotPromoteQF />

Open in new window

0
Comment
Question by:justmelat
9 Comments
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 37740632
It is a problem with your content placed from MS Word document etc.,   Before you copy/paste to the editor .. you need to strip or remove those word formatting .. there is feature in CKEditor.
0
 
LVL 9

Accepted Solution

by:
rinfo earned 500 total points
ID: 37741626
These are html comments that has been included for being used in copy paste.
You should provide provision to strip such comments by using
html = html.replace("(?s)<!--\\[if(.*?)\\[endif\\] *-->", "") in a java script.
and it will take care of  such insertions.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37741679
I can't vouch for this, but it seems promising.
http://www.tinymce.com/wiki.php/Plugin%3apaste
0
 
LVL 1

Author Comment

by:justmelat
ID: 37742129
Hi Ray

I tried adding paste in the init but something is still off in this:
 
After many hours of this, here is another kink.  In more researching I found some issues with copy/paste in tinyMCE, so in a desperate move, I took the clients' text and just re-typed it in myself, adding no formatting.  

I started paragraph by paragraph.  The first one went in/displayed fine, as well as the second, third, all the way to the 6, when I got to the seventh paragraph, saved everything, went back to the form to view, nothing from the textarea field would display.  There is even a border around this section, it would not display.  I went back to the db, all the text is still there [no funky MS code], but will not display on the form.  Are there some limitations as it relates to the textarea field that I am not aware of?  

I have increased the column rows to 30 for the textarea field, changed the field type in the db from a **text** field to a **mediumtext** field.  Did all that and still, once I get to a certain point, nothing displays.  Any suggestions on what I am missing?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37742271
No suggestions, sorry.  I have never seen TinyMCE malfunction in the way you describe.  And with only a few paragraphs of data you are certainly not hitting limits that would lead to data truncation.

My experience with TinyMCE goes like this.  If you are a really naive client, you will just type your information into the textarea and everything will work well.  If you are a really sophisticated client you will know well enough not to paste MSFT formatting into any textarea and everything will work well.  But if you're both clever and unsophisticated you can screw things up completely.  

I once wrote a CMS for a client who insisted on doing their own updates to the web pages.  After about two months of destroying the formatting and content of their pages, they gave up and went back to paying me to do their updates.  I think if they had just spent the two months learning a little HTML they would have been way ahead!  That's probably not going to help you solve your TinyMCE issues, but at least you know that you have company in those trenches.
0
 
LVL 1

Author Comment

by:justmelat
ID: 37742375
LOL - good one Ray.  The tinyMCE has been in place and working for two years, so not sure what changed so much, except that originally the client did copy/paste from a word doc.  But now that I have re-typed everything - that issue is no longer relevant.  

And you are right, even with these 8 paragraphs the client has, it't not like a novel or anything. so I don't know what is going on and worse, I can't confirm that it's tinyMCE, or textarea field, or the db or the browsers.  

Not sure which I hate worse, having a big, complex issue to figure out or having a seemingly small issue that takes you thru hundreds of hoops.

Thanks for your comments - I do appreciate your time.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 37742557
Do you have phpMyAdmin?  If not, get it.  It will give you an easy way to look into the DB and fix things that need hands-on work.
0
 
LVL 1

Author Comment

by:justmelat
ID: 37742666
i have phpAdmin, but also have navicat - really nice, simple db interface.  And from it, I can see that all the text is in the field, it just won't show up on the form at a certain point.
0
 
LVL 1

Author Closing Comment

by:justmelat
ID: 37743380
great as usual
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now