xProteuSx Posted December 28, 2008 Share Posted December 28, 2008 I have something that looks like this: <a href="http://www.mysite.com/nation.php?country=Bosnia & Herzegovina"> The country listing at the end of the link is generated out of a database. Ofcourse, this doesn't really work. I can't have spaces in the link, but that is how the names have to be in the database. Is there any php command, or series of commands, that can help me get around this without having to insert '20%' into the link? Because 'Bosnia & Herzegovina' is really a value from a database, and for other reasons, I can't have 20%'s in there. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/138600-solved-spaces-and-_get-and-_post/ Share on other sites More sharing options...
Infected.Shadow Posted December 28, 2008 Share Posted December 28, 2008 I noticed you tried '20%'. The correct format is '%20', maybe try it that way? Quote Link to comment https://forums.phpfreaks.com/topic/138600-solved-spaces-and-_get-and-_post/#findComment-724703 Share on other sites More sharing options...
xProteuSx Posted December 28, 2008 Author Share Posted December 28, 2008 Yeah, sorry, ofcourse. The only thing is that I cannot have fillers like this at all. I need actual spaces in there because in most instances I use that database to output the data as plain text, and not html, and if I replace spaces with %20 then all text will contain this html. Quote Link to comment https://forums.phpfreaks.com/topic/138600-solved-spaces-and-_get-and-_post/#findComment-724708 Share on other sites More sharing options...
premiso Posted December 28, 2008 Share Posted December 28, 2008 replace the spaces with _'s and use str_replace to go back and forth. Simple as that. Quote Link to comment https://forums.phpfreaks.com/topic/138600-solved-spaces-and-_get-and-_post/#findComment-724711 Share on other sites More sharing options...
MadTechie Posted December 28, 2008 Share Posted December 28, 2008 Or use the built in url encoder... urlencode() Quote Link to comment https://forums.phpfreaks.com/topic/138600-solved-spaces-and-_get-and-_post/#findComment-724712 Share on other sites More sharing options...
xProteuSx Posted December 28, 2008 Author Share Posted December 28, 2008 Thanks very much for all the replies. I have incorporated urlencode() and urldecode() into the page, and it works beautifully, so thanks MadTechie. premiso, thanks for your idea. I can see that it would work. However, after having consulted the PHP manual for urlencode() and urldecode() this was the simplest route for me. Thanks anyways. I love this site. Thanks guys. Quote Link to comment https://forums.phpfreaks.com/topic/138600-solved-spaces-and-_get-and-_post/#findComment-724716 Share on other sites More sharing options...
premiso Posted December 28, 2008 Share Posted December 28, 2008 Thanks very much for all the replies. I have incorporated urlencode() and urldecode() into the page, and it works beautifully, so thanks MadTechie. premiso, thanks for your idea. I can see that it would work. However, after having consulted the PHP manual for urlencode() and urldecode() this was the simplest route for me. Thanks anyways. I love this site. Thanks guys. Eh no worries. Better to have 5 different choices than just one. If you are looking for SEO Friendly I would recommend my idea and even replace the & with and. If not MadTechie way works great and is probably easier to implement! Quote Link to comment https://forums.phpfreaks.com/topic/138600-solved-spaces-and-_get-and-_post/#findComment-724732 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.