can you confirm if it solves your problem?
Main Topics
Browse All TopicsI'm having issues trying to protect my website when I allow users to leave comments. When a user leaves a comment, they are presented with the following input fields:
- Name
- Email
- Website URL
- Comment
I do two checks to protect my website:
(1) I check the data and make sure it's safe to place in my data
(2) When people view the comments, I sanitize it
My problem is when I sanitize the information, I use the following code:
function magicquotes_sanitize($str)
if (!function_exists("get_mag
if (get_magic_quotes_gpc()) $str=stripslashes($str);
return $str;
}
function sql_sanitize($in,$sanitize
$in=magicquotes_sanitize($
$out=mysql_real_escape_str
if ($sanitize_like==true) $out=addcslashes($out,"%_"
return $out;
}
I run sql_sanitize on the input data. But, when I display it back out, I have a "\" whenever a user makes a URL like: http://www.myspace.com/thi
So, it outputs: http://www.myspace.com/thi
How can I safely fix this issue? Can I just get rid of the backslash when I display it? And will it be safe?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: khaledfPosted on 2008-09-17 at 18:48:34ID: 22506162
if ($sanitize_like==true) $out=addcslashes($out,"%_" ); ;
shouldn't it be ?
if ($sanitize_like==true) $out=addcslashes($out,"%")