PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 23rd, 2009, 01:27 PM
jamestrowbridge jamestrowbridge is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2008
Location: Cleveland, Ohio, USA
Posts: 411 jamestrowbridge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 18 h 54 m 24 sec
Reputation Power: 2
Pasting into TinyMCE

Not sure if this will turn out to be a client side issue (within TinyMCE) or if I need to do something special in PHP to fix this

I'm trying to copy an email, paste it into TinyMCE, and then submit it to a MySQL DB.

Example email after being pasted into TinyMCE (source code according to TinyMCE's 'HTML' button):
PHP Code:
<p>Message.&nbspBlah blah blah</p>
<
p>&nbsp;</p>
<
p>Thanks,</p>
<
p>&nbsp;</p>
<
p>Jim Smith</p>
<
p>Tech Support</p>
<
p>Company Associates</p>
<
p>555-555-5555</p>
<
p>&nbsp;</p>
<
p><strong>From:</strongTommy [mailto:tommy@email.com] <br /> <strong>Sent:</strongMondayOctober 052009 8:57 AM<br /> <strong>To:</strongJim<br /> <strong>Subject:</strongRESubject of email</p>
<
p>&nbsp;</p>
<
p>Jim-</p>
<
p>&nbsp;</p>
<
p>How about tomorrow?</p>
<
p>&nbsp;</p>
<
p>Thank you.</p>
<
p>&nbsp;</p>
<
p>-Tommy</p>
<
p>&nbsp;</p>
<
hr size="2" />
<
p><strong>From:</strongJim [mailto:jim@email.com] <br /> <strong>Sent:</strongSaturdayOctober 032009 12:42 PM<br /> <strong>To:</strongTommy<br /> <strong>Subject:</strongSubject of email</p>
<
p>&nbsp;</p>
<
p>Tommy,</p>
<
p>&nbsp;</p>
<
p>Blah Blah Blah message message message blah.</p>
<
p>&nbsp;</p>
<
p>Thanks,</p>
<
p>&nbsp;</p>
<
p>Jim Smith</p>
<
p>Tech Support</p>
<
p>Company Associates</p>
<
p>555-555-5555</p


PHP/MySQL code to insert into DB:
PHP Code:
 $insert_sql="INSERT INTO tbl1 (
comments, 
added_date, 
added_by, 
parent_node

values(
 '"
.mysql_real_escape_string($_POST['notes'])."',
 FROM_UNIXTIME("
.$timestamp."),
 '"
.$_SESSION['csv_username']."',
 '"
.mysql_real_escape_string($_POST['parent_node'])."'
 )"



After running through this code, this is what is stored in the DB for the record in the comments column:
PHP Code:
<p>Message


Any ideas on what the problem could be?
__________________
Sir, a desire of knowledge is the natural feeling of mankind; and every human being, whose mind is not debauched, will be willing to give all that he has to get knowledge.

Last edited by jamestrowbridge : October 23rd, 2009 at 01:29 PM.

Reply With Quote
  #2  
Old October 23rd, 2009, 01:42 PM
jamestrowbridge jamestrowbridge is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2008
Location: Cleveland, Ohio, USA
Posts: 411 jamestrowbridge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 18 h 54 m 24 sec
Reputation Power: 2
I hate how in order to trigger ideas, I have to post in a forum sometimes..

After some more testing, it looks like the & is messing things up, like when using &nbsp; because I'm using jquery ajax(), with the data line:
PHP Code:
 data'parent_node=' parent_node '&email_coordinator=' email_coordinator '&client_number=' client_number '&notes=' notes


if the javascript variable 'notes' contains an &, it thinks it's starting a new variable. I'll have to look that up and then I'll post the fix when I find it, so far.. sorry for the pointless thread.

Reply With Quote
  #3  
Old October 23rd, 2009, 01:50 PM
IAmALlama IAmALlama is offline
Me
Click here for more information. Click here for more information
Click here for more information
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 1,937 IAmALlama User rank is Private First Class (20 - 50 Reputation Level)IAmALlama User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 5 Days 1 h 54 m 18 sec
Reputation Power: 4
i believe you can use the javascript escape() to escape the string and convert characters like & to their %NN equivalent.

Reply With Quote
  #4  
Old October 23rd, 2009, 03:51 PM
jamestrowbridge jamestrowbridge is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2008
Location: Cleveland, Ohio, USA
Posts: 411 jamestrowbridge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 18 h 54 m 24 sec
Reputation Power: 2
AWESOME! Thank you Llama,
changed to:
PHP Code:
 data'parent_node=' parent_node '&email_coordinator=' email_coordinator '&client_number=' client_number '&notes=' escape(notes), 
Now it's working properly

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Pasting into TinyMCE


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek