Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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
Medium Priority
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

Question by:justmelat
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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.

Accepted Solution

rinfo earned 2000 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.
LVL 111

Expert Comment

by:Ray Paseur
ID: 37741679
I can't vouch for this, but it seems promising.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

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?
LVL 111

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.

Author Comment

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.
LVL 111

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.

Author Comment

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.

Author Closing Comment

ID: 37743380
great as usual

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

721 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