htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Discussion:
quote problems saving to mysql with php


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


@church
New User

Nov 10, 2003, 7:37 AM

Post #1 of 6 (4782 views)
Shortcut
quote problems saving to mysql with php Can't Post

Hi everybody,

I have a strange problem. I have two different situations:

1. I enter HTML, text, double quotes, single quotes etc. in a normal textarea, I put it in the database and all is well.

2. I enter HTML, text, double quotes, single quotes etc. in a htmlArea v3.0 - Beta Release textarea, But the mysql query is broken by the double quotes and it will not be saved in the database.

This means that the two area's have a different output. What happens to the double quotes in htmlArea v3.0 - Beta Release textarea that It's different from a normal textarea ?

Normally I alway use this php database post check (php.net):

-----------------------------------------------------------------------------------------------

$search = array ("'<script[^>]*?>.*?</script>'si", // Strip out javascript
"<script>",
"'&(quot|#34);'i", // Replace html entities
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(\d+);'e"); // evaluate as php

$replace = array ("",
"",
"\"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\\1)");

${$res} = preg_replace ($search, $replace, ${$res});

-----------------------------------------------------------------------------------------------

I took out this part because we don't want the html tags to be stripped:

"'<[\/\!]*?[^<>]*?>'si", // Strip out html tags


The above code works for a normal textarea but not for htmlArea. How is that possible ?

greets,

@church


tenke
Novice

Nov 10, 2003, 10:34 AM

Post #2 of 6 (4771 views)
Shortcut
same here.. [In reply to] Can't Post

@church,

I'm having the exact same issue using ASP & MySQL. If you get any info on how to fix this, please email me at troy AT boundless DOT net. I know the languages are different but perhaps it can shed some light on an ASP solution as well..



thanks!

Troy


@church
New User

Nov 10, 2003, 12:08 PM

Post #3 of 6 (4766 views)
Shortcut
Re: [tenke] same here.. [In reply to] Can't Post

I've used htmlentities().

This is a functionality in Php which acts like 'the underwater screen in wordperfect'; it shows all the tags and quotes but they are disabled. All characters which have HTML character entity equivalents are translated into these entities. If you would show it in a browser you'd see the tags and all. With htmlentities I can save everything in a right harmless manner into the database.

And with unhtmlentities() I reverse the process when I get de data out of the database onto my site.

You can read about the functionality here:

http://nl.php.net/manual/en/function.htmlentities.php

There should be something simular in ASP. Maybe you can use the terminology mentioned on the Php site in your search for your ASP functionality.

I preferred this over: addslashes() / stripslashes()


Triniti
Novice

Mar 6, 2004, 1:02 PM

Post #4 of 6 (4462 views)
Shortcut
Re: [@church] same here.. [In reply to] Can't Post

I have a problem like this....

I wrote it at:
http://www.interactivetools.com/forum/gforum.cgi?post=24801;sb=post_latest_reply;so=ASC;forum_view=forum_view_collapsed;;page=unread#unread

Can anyone help?

Triniti


troostmarco
New User

Mar 8, 2004, 1:30 AM

Post #5 of 6 (4442 views)
Shortcut
Re: [@church] quote problems saving to mysql with php [In reply to] Can't Post

Hi,

It seems to me that you are complicating things for yourself. If I were you, i'd use just a line or 2 of php instead of the bulk of code you are using now. What about:

$SaveContent = addslashes(strip_tags($_REQUEST['ta'], '<B><A>,<IMG>,<h1>,<ul>,<ol>,<li>,<other tags you allow to be saved>'));

works for me,

grtz Marco


chalexan
Novice

Mar 10, 2004, 12:10 PM

Post #6 of 6 (4396 views)
Shortcut
Re: [@church] quote problems saving to mysql with php [In reply to] Can't Post

If your trying to save the body of the htmlarea to your database and keep all of your tags, one solution is to use a php fuction str_replace.

$tempValue = str_replace('"','*',$_POST[ta]);

You can save this string into the database because it has no quotes in it. Then to reverse it to the original text, just switch the characters.


$tempValue = str_replace('*','"',$_POST[ta]);

 
 
 


Search for (options)