Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


TinyMCE and PHP - Adding Extra Characters

Posted on 2013-01-10
Medium Priority
Last Modified: 2013-01-24
I have never had this problem before.   I am using PHP and TinyMCE together to be able to send an email with HTML coding.    Something weird is happening - TinyCME and/or PHP is adding an extra "\ at the beginning of the <A HREF tag so a link in the email doesn't work.   I have never had this happen before but I have never used PHP with TinyMCE so I am not sure which side to blame.

This is the form field:

<TR><TD valign="top"><strong>Message</strong>:</TD><TD><textarea name="EmailMessage" class="tinymce" rows="15" cols="70"></textarea></TD></TR>

Open in new window

This is what I am using for the body of the email (but it also outputs to the screen incorrectly with an echo statement.

fputs($fd, $_POST['EmailMessage'] ."\n");

Open in new window

So if i have http://www.test.org as the link it gets written out as /"http://www.test.org which doesn't work.   Any ideas??
Question by:digitalwise
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 12

Expert Comment

ID: 38765439
Did you enter the link yourself? Can you replicate tinyMCE adding the slash and double quote? What happens if you delete it from the HTML view in tinyMCE?

Note that "\ and /" are very different things. The backslash is the escape control character in php as I'm sure you're aware. while the front slash is not a control character.

Post the HTML generated by tinyMCE?

Add a new link and replicate the issue.

Author Comment

ID: 38767179
This is replicable - it does it every time for every user.   If I enter stuff in the TinyMCE box that looks like this under HTML view.   <p>This is a test of the <a href="http://www.google.com">link</a>.</p>   The resulting HTML is
<p>This is a test of the <a href=\"http://www.google.com\">link</a>.</p>
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 38785655
@jessegivy asked if you would post your code.  That will be a big help.  The best thing to do is save the file as a static html page and post a link to it so we can see all the html, css and js.
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.

LVL 51

Expert Comment

by:Steve Bink
ID: 38786777
It sounds like your code is escaping the form input, as if it would be saved in a database.  That's fine, if you're actually saving it in a database, but the escaped version of the text should not be used for distribution.
LVL 111

Expert Comment

by:Ray Paseur
ID: 38786815

Author Comment

ID: 38787370
This is the code  
while ($row = mysql_fetch_assoc($result)) {
	$fd = popen("/usr/sbin/sendmail -t","w") or die("Couldn't Open Sendmail");
    fputs($fd, "To: " .$row['Email'] ." \n");
    fputs($fd, "From: " .$_POST['SendFrom'] ." \n");
    fputs($fd, "Subject:" .$_POST['Subject']. "\n");
	fputs($fd, "Content-type: text/html \n");
    fputs($fd, "X-Mailer: PHP3 \n\n");
	fputs($fd, $_POST['EmailMessage'] ."\n");

Open in new window

I already posted the form field above.   There is much else to it other than the links to the tinymce jscript.

I did just try adding the
	fputs($fd, mysql_real_escape_string($_POST['EmailMessage']) ."\n");

Open in new window

but that made it worse with \\\ at the beginning and end of the URL in the email message.
LVL 111

Expert Comment

by:Ray Paseur
ID: 38789928
Please run this script, shown here in its entirety.  Scan the output for magic_quotes_gpc and tell us what you find.

<?php phpinfo();

Open in new window

Thanks, ~Ray

Author Comment

ID: 38805694
magic_quotes_gpc      On      On
LVL 111

Accepted Solution

Ray Paseur earned 2000 total points
ID: 38808310
magic_quotes_gpc is possibly the problem.  Please read the article and post back if there is anything in it that you do not understand.


Author Closing Comment

ID: 38816922
I had to use the script in the reference and not use the other coding...

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses how to implement server side field validation and display customized error messages to the client.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

597 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