kjharve Posted August 8, 2009 Share Posted August 8, 2009 Hi all. The site I am working uses query strings in some of the admin functions. A list of users is displayed and the functions you can perform on their accounts are written as hyperlinks. I've already got one user registered "O'Neill" and although my queries work ok, the admin functions won't. Here's the code: echo "<a href='admin.php?changeuser=$changeuser&criteria=admin'>Change</a>"; The URL that is output is as follows: admin.php?changeuser=o I really want the URL to be: admin.php?changeuser=o'neill&criteria=admin Using addslashes simply adds a \ on the end of the URL. Can anyone help me with this? Thanks. Kev Quote Link to comment https://forums.phpfreaks.com/topic/169347-solved-name-with-apostrophe-in-query-string/ Share on other sites More sharing options...
wildteen88 Posted August 8, 2009 Share Posted August 8, 2009 You should use urlencode when setting your url, eg $changeuser = urlencode($changeuser); echo "<a href='admin.php?changeuser=$changeuser&criteria=admin'>Change</a>"; Now when you use $_GET['changeuser'] use urldecode, eg $changeuser = urldecode($_GET['changeuser']); Quote Link to comment https://forums.phpfreaks.com/topic/169347-solved-name-with-apostrophe-in-query-string/#findComment-893608 Share on other sites More sharing options...
kjharve Posted August 8, 2009 Author Share Posted August 8, 2009 Superb - works a treat. Knew it'd be something easy ;-) Quote Link to comment https://forums.phpfreaks.com/topic/169347-solved-name-with-apostrophe-in-query-string/#findComment-893636 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.