dub_stylee Posted December 8, 2008 Share Posted December 8, 2008 Hello, I am running into another small (but hopefully simple) problem. I am querying my database by album name; everything works fine except for when I encounter album names such as "Kill 'Em All" or "S&M". I am passing the album name to a PHP script via: /processalbum.php?album_name=S&M I have also tried: /processalbum.php?album_name=S&M but this doesn't seem to work either. I have a similar problem with "Kill 'Em All" because it cuts off the album name at the apostrophe. Does anyone have any suggestions on how to handle this situation? Thanks in advance, Brian Link to comment https://forums.phpfreaks.com/topic/136015-handling-special-characters-in-php/ Share on other sites More sharing options...
corbin Posted December 8, 2008 Share Posted December 8, 2008 http://php.net/urlencode should do it. Link to comment https://forums.phpfreaks.com/topic/136015-handling-special-characters-in-php/#findComment-709177 Share on other sites More sharing options...
darkfreaks Posted December 8, 2008 Share Posted December 8, 2008 <?php $replace=preg_replace("&","&",$replace); ?> Link to comment https://forums.phpfreaks.com/topic/136015-handling-special-characters-in-php/#findComment-709179 Share on other sites More sharing options...
corbin Posted December 8, 2008 Share Posted December 8, 2008 <?php $replace=preg_replace("&","&",$replace); ?> When would he ever use that? In a URL, & is no more valid than ?var1=val&something; would be. & is a reserved character, straight up. %26 is used for & in a URL because 26 is the decimal representation of the ASCII-number value of &. Link to comment https://forums.phpfreaks.com/topic/136015-handling-special-characters-in-php/#findComment-709183 Share on other sites More sharing options...
dub_stylee Posted December 8, 2008 Author Share Posted December 8, 2008 Thanks corbin! urlencode() did the trick. Everything is working perfectly now. Brian Link to comment https://forums.phpfreaks.com/topic/136015-handling-special-characters-in-php/#findComment-709185 Share on other sites More sharing options...
corbin Posted December 8, 2008 Share Posted December 8, 2008 No prob. Edit: By the way, in case you look into it later or something, when I said decimal representation earlier, I should have said hexidecimal. Link to comment https://forums.phpfreaks.com/topic/136015-handling-special-characters-in-php/#findComment-709189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.