简体   繁体   中英

\\\\r\\\\n\\\\r\\\\n Characters appearing after text inserted into a form in PHP

I have a form that processes text like this:

$group_description = mysql_real_escape_string(trim($_POST['group_description']));

$insert_group_sql =  'INSERT INTO table_name( group_description ) 
VALUES ( "'.$group_description.'" ') ';

And another page that outputs the db results like this:

$group_description = $row['group_description'];

//Convert all urls to links
$group_description = preg_replace('#([\s|^])(www)#i', '$1http://$2', $group_description);
$pattern = '#((http|https|ftp|telnet|news|gopher|file|wais):\/\/[^\s]+)#i';
$replacement = '<a href="$1" target="_blank">$1</a>';
$group_description = preg_replace($pattern, $replacement, $group_description);

$group_description = str_replace(array('\r\n', '\n\r'), '<br />',$group_description);

/* Convert all E-mail matches to appropriate HTML links */
$pattern = '#([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.';
$pattern .= '[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)#i';
$replacement = '<a href="mailto:\\1">\\1</a>';
$group_description = preg_replace($pattern, $replacement, $group_description);

What I ended up with was this page: http://www.comehike.com/hikes/hiking_group.php?hiking_group_id=54

And I am not too sure how this user got the \\r\\n characters to get in there:)

Any idea where things went wrong? I use a MySQL database if that is important. Thanks!

Read up on PHP magic quotes and then think about upgrading php version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM