Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi guys i would like to ask how do we save a special character into mysql? the situation is that i'm using tinymce for word editor. now when i type in something and put some styling in that editor its working fine when i save it in the database base. but the problem is when i type in a special character such as
<  or  > 
. when i try to view the generated word of tinymce
instead of returning < it returns "< ;"
and that how it should be. but when i try to execute the query all of the text after the special character
< ;
are gone.

I really dont know how to save it anymore... Assuming that the tinymce generated this kind of content
<span style="color: #888888;">This is the content generated by tinymce</span> and this is the special character &lt; and a greater than sign &gt;


I wish to save this content but the problem is all the character in between &lt; and &gt; are all erase.... how do i save this and same time retrieve and display it on tinymce? so i would like it to be display in tinymce as this

<span style="color: #888888;">This is the content generated by tinymce</span> and this is the special character < and a greater than sign >
Posted

I already found the problem... I found out that in my JS file im passing the content of tinymce using this function tinyMCE.get("tiny").getContent() but the problem with this is that when the editor contains this character "<" it interpret it as "<" then when i submit it in ajax when php read that post data it consider the "<" as another parameter pass... so what i did was to use encodeURIComponent(tinyMCE.get("tiny").getContent()) and it finally solve the problem
 
Share this answer
 
What character set are you using? INSERT using Latin1 character set
 
Share this answer
 
Try using the mysql_real_escape_string() method[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900