note 56401 added to function.addslashes
| From: | (lmaxcar@yahoo.com.br) | Date: | Thu, 01 Sep 2005 13:16:47 +0000 |
| Subject: | note 56401 added to function.addslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94596@lists.php.net to get a copy of this message | ||
Hello,
If you are getting trouble to SGDB write/read HTML data, try to use this:
<?php
//from html_entity_decode() manual page
function unhtmlentities ($string) {
$trans_tbl =get_html_translation_table (HTML_ENTITIES );
$trans_tbl =array_flip ($trans_tbl );
return strtr ($string ,$trans_tbl );
}
//read from db
$content = stripslashes (htmlspecialchars ($field['content']));
//write to db
$content = unhtmlentities (addslashes (trim ($_POST['content'])));
//make sure result of function get_magic_quotes_gpc () == 0, you can get strange slashes in your
content adding slashes twice
//better to do this using addslashes
$content = (! get_magic_quotes_gpc ()) ? addslashes ($content) : $content;
?>
----
Manual Page -- http://www.php.net/manual/en/function.addslashes.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56401
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56401&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56401&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56401&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56401&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56401&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56401&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56401&report=yes
Search -- http://master.php.net/manage/user-notes.php