Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Mysql CodeIgniter Converting characters to symbols in very bizarre circumstances
    text
    copied!<p>PHP Mysql CodeIgniter Converting characters to symbols in very bizarre circumstances</p> <ul> <li>Application Built on CodeIgniter.</li> <li>Has been running for over a year. No problems.</li> <li>Client fills in a form about a customer.</li> <li>A simple <strong>trim($_POST['notes'])</strong> captures textarea form field text and saves to MySQL</li> <li>no error reported in PHP or JavaScript</li> <li>The other day I notice some text the client has entered, has had the brackets used in the text "<strong>()</strong>" replaced with the equivalent <strong>"<code>&amp;#40;&amp;#41</code>;</strong></li> <li>I think... "That's strange... I don't recall any reason why those characters would have been replaced like that.!"</li> </ul> <p>I take a look ... and a day later... here is my madness revealed:</p> <hr> <p>The text in question is verbatim " <strong>Always run credit card on <em>file</em> (we do not charge this customer for pick-up or return)</strong> "</p> <p>No matter what I did or changed on the code side.. I could not prevent the PHP... OR Javascript... Or MySQL... OR alien beings... - or whoever the heck is doing it - from converting the "<strong>()</strong>" in the text to <strong>"<code>&amp;#40;&amp;#41</code>;</strong>. And I tried many things like cleaning the string in all ways known to man or god. Capturing the string previous to sending just before saving to the database. And the conversion would always take place just before the save to MySQL. I tried posting in different forms and fields... Same thing every time... could not stop the magic conversion to <strong>"<code>&amp;#40;&amp;#41</code>;</strong>.</p> <p>What in the name of batman is in this magical text that is causing this to happen?? is it magic pixie dust sprinkled on to godaddy server it is running on??? 0_o .......</p> <p>Being the genius that I am 0_0 I decide to remove one word from the paragraph at a time. Magically... as all the creatures of the forest gathered around - as I finally got to the word "<strong><em>file</em></strong>" in the paragraph, and removed it !!! Like magic - the "<strong>()</strong>" stay as "<strong>()</strong>" and are <strong>NOT</strong> converted to <strong>"<code>&amp;#40;&amp;#41</code>;</strong>?!?!???!?!? :\ How come??I simply removed the word "<strong>file</strong>" from the text... How could this change anything?? What is the word "<strong>file</strong>" causing to change with how the string is saved or converted??</p> <hr> <p>OK -So I tested this out on any and every form field in the app. Every single time, in any field, if you type the word "<strong>file</strong>" followed by a "<strong>(</strong>" it will convert the first "<strong>(</strong>" to <strong>"<code>&amp;#40;</code>;</strong> and the very next "<strong>)</strong>" to <strong>"<code>&amp;#41</code>;</strong></p> <p>So.. if the string is:</p> <p>"<strong>file ( any number of characters or text ) any other text or characters</strong>"</p> <p>On post, it will be converted mysteriously to:</p> <p>"<strong>file <code>&amp;#40;</code> any number of characters or text <code>&amp;#41</code> any other text or characters</strong>"</p> <p>Remove the word "<strong>file</strong>" from the string, and you get:</p> <p>"<strong>( any number of characters or text ) any other text or characters</strong>"</p> <p>The alien beings return the abducted "<strong>()</strong>" </p> <hr> <p>Anyone have a clue what the heck could be going on here?</p> <hr> <ul> <li><p><strong>What is causing this?</strong></p></li> <li><p><strong>Is the word "file" a keyword that is tripping some sort of security measures? interpereting it as "file()"???</strong> </p></li> </ul> <hr> <p>I dunno :\</p> <p>It's the strangest thing I ever saw... Except for that time I walked in on Mom and Dad <strong>0_o</strong></p> <p>Any help would be greatly appreciated, and I will buy you a beer for sure :)</p> <hr> <p>The very large headed, - (way to much power for such tender egos) -, Noo-Noos here at stack have paused this question as "Off topic" LOL... honest to <strong>God</strong> these guys are so silly.</p> <p>So - in an effort to placate the stack-gestapo - I will attempt to edit this question so that it is... "on topic"??? 0_o ... anything for you oh so "King" Stack Guys O_O - too bad you would never have the whit to ever notice such a bug... maybe some day. ;)</p> <hr> <p>Sample code:</p> <pre><code> &lt;textarea name="notes"&gt;Always run credit card on file (we do not charge this customer for pick-up or return) blah blah&lt;/textarea&gt; &lt;?php if(isset($_POST['notes']){ $this-&gt;db-&gt;where("ID = ".$_POST['ID']); $this-&gt;db-&gt;update('OWNER', $_POST['notes']); } ?&gt; </code></pre> <hr> <p><strong>Resulting MySQL storage:</strong> <br> "Always run credit card on file <code>&amp;#40;</code>we do not charge this customer for pick-up or return<code>&amp;#41;</code> blah blah"</p> <ul> <li>InnoDB - Type text utf8_general_ci</li> </ul> <p><strong>I am not looking for a way to prevent it, or clean it... I am clearly asking "What causes it"</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload