0

Here is my code

$user_data = "I'm awesome";
echo $user_data;

This for some reason echoes I\'m awesome in my site. I found this odd and weird. I put it in a variable because the value of this changes within the action of a function, searching through a MySQL Database. I cannot find the problem. Please HELP!

DCV_Diego
  • 13
  • 1
  • 1
  • 7
  • 3
    You probably have magic quotes enabled. [Disable them](http://php.net/security.magicquotes.disabling). – Amal Murali Apr 10 '14 at 19:51
  • Update your Webserver. magic quotes are deprecated since 5.3 and DISABLED since 5.4 - you have to have an old PHP version. – Xatenev Apr 10 '14 at 19:53
  • Possible duplicate [question](http://stackoverflow.com/questions/1522313/php-mysql-real-escape-string-stripslashes-leaving-multiple-slashes) – Nathan Apr 10 '14 at 19:53

1 Answers1

1

I would use stripslashes() function

$user_data = "I'm awesome";
$user_data = stripslashes($user_data);
echo $user_data;
Kevin Lynch
  • 24,427
  • 3
  • 36
  • 37
  • 1 point to this: If stripslashes is NOT working for deleting backslashes, you probably have 'magic_quotes_sybase' activated. When it's activated, one backslash won't be removed, but two backslashes will be replaced with one. – Xatenev Apr 10 '14 at 20:00
  • Yeah I know, realized right after I posted the question! Can't delete it now, thanks anyways :D – DCV_Diego Apr 10 '14 at 20:00
  • Glad you have got it fixed. Hopefully this will help others that have the same problem in the future. – Kevin Lynch Apr 10 '14 at 20:05