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
452 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 109

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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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
 
LVL 109

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 109

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

840 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