Patrick3002 Posted February 21, 2007 Share Posted February 21, 2007 Hi, i was wondering if anyone knows the function to escape characters like & from a string? Thanks! Link to comment https://forums.phpfreaks.com/topic/39434-escape-characters/ Share on other sites More sharing options...
Guest Posted February 21, 2007 Share Posted February 21, 2007 Hey, depends on the destination. If you want it in the url, you use urlencode($string) -- then urldecode($string) when you need it back to normal. If for a webpage, use htmlentities($string, ENT_QUOTES), and htmlspecialchars($string, ENT_QUOTES) to revert them back. If for a mysql database, use mysql_real_escape_string($string, $database_resource) For the simplest and easiest, but least secure: addslashes($string), and the opposite: stripslashes($string) Link to comment https://forums.phpfreaks.com/topic/39434-escape-characters/#findComment-190275 Share on other sites More sharing options...
Patrick3002 Posted February 21, 2007 Author Share Posted February 21, 2007 Ok, i will try those. I am escaping it from lyric.php?artist=Brooks%20&%20Dunn&pc=B Link to comment https://forums.phpfreaks.com/topic/39434-escape-characters/#findComment-190278 Share on other sites More sharing options...
Guest Posted February 21, 2007 Share Posted February 21, 2007 ah yep, then for that you'd use urlencode($string) Link to comment https://forums.phpfreaks.com/topic/39434-escape-characters/#findComment-190279 Share on other sites More sharing options...
Patrick3002 Posted February 21, 2007 Author Share Posted February 21, 2007 It doesn't want to work for what im doing... Link to comment https://forums.phpfreaks.com/topic/39434-escape-characters/#findComment-190281 Share on other sites More sharing options...
Patrick3002 Posted February 21, 2007 Author Share Posted February 21, 2007 The lyrics and everything else doesn't show up because of an & symbol in the artist variable. http://patricks.kicks-ass.net/lyrics/lyric.php?artist=Pat+%26+Trick&pc=P Link to comment https://forums.phpfreaks.com/topic/39434-escape-characters/#findComment-190283 Share on other sites More sharing options...
Patrick3002 Posted February 21, 2007 Author Share Posted February 21, 2007 I need to escape an & symbol from a var in a link like /find.php?pc=b & c Link to comment https://forums.phpfreaks.com/topic/39434-escape-characters/#findComment-190295 Share on other sites More sharing options...
Patrick3002 Posted February 21, 2007 Author Share Posted February 21, 2007 No one has a solution for me? Link to comment https://forums.phpfreaks.com/topic/39434-escape-characters/#findComment-190308 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.