Jump to content

Escaping Characters


sean04

Recommended Posts

Hey,

 

So as of right now i'm escaping characters as follows:

 

$Name = htmlspecialchars(mysql_real_escape_string($_POST['Name']));

 

When I edit my name to something like this "Sean's" the output will be "Sean\'s"

I expected this but how can it just appear as "Sean's" but still escape characters?

I know there are some functions and stuff out there or ways around it..

 

Thanks,

Sean

 

Link to comment
https://forums.phpfreaks.com/topic/199129-escaping-characters/
Share on other sites

If you can visibly see the backslash character then it is being double escaped, this is probably because you have magic_quotes enabled on the server. You can use something like

 

if(get_magic_quotes_gpc()) {
   stripslashes($var);
}
$var = mysql_real_escape_string($var);

Link to comment
https://forums.phpfreaks.com/topic/199129-escaping-characters/#findComment-1045123
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.