mommydaddy Posted May 7, 2008 Share Posted May 7, 2008 Here is my problem: When I do something like "echo $_GET['myvar']", it only prints part of 'myvar'. The value of myvar has some # signs in it. Everything after the first # is omitted. Anyone know how I can work around this? Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/ Share on other sites More sharing options...
DarkWater Posted May 7, 2008 Share Posted May 7, 2008 It works on my server....Even with the # signs. O_O Try putting it in double quotes... echo "{$_GET['myvar']}"; Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/#findComment-535570 Share on other sites More sharing options...
mommydaddy Posted May 7, 2008 Author Share Posted May 7, 2008 Thanks for the response, but it still doesn't work. Any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/#findComment-535579 Share on other sites More sharing options...
rarebit Posted May 7, 2008 Share Posted May 7, 2008 mmm works fine for me locally and on site... but do as DarkWater says... what system are you on? what server? Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/#findComment-535580 Share on other sites More sharing options...
DarkWater Posted May 7, 2008 Share Posted May 7, 2008 $myvar = $_GET['myvar']; echo $myvar; Try that....If it doesn't work, then try this and tell me if it works so we can actually tell if it's the "#" that's causing it: echo str_replace("#", "", $_GET['myvar']); Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/#findComment-535581 Share on other sites More sharing options...
mommydaddy Posted May 7, 2008 Author Share Posted May 7, 2008 rarebit: I am using PHP 5.2.3 on Solaris 5.10. DarkWater: Doing $myvar=$_GET['myvar']; doesn't fix things. If I do the echo str_replace, on (what is supposed to be) "asdf#asdf", it spits out "asdf". Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/#findComment-535593 Share on other sites More sharing options...
benphp Posted May 7, 2008 Share Posted May 7, 2008 try adding another fake var at the end of your string: http://www.mysite.com/myscript.php?myvar=asdf#asdf&x=x Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/#findComment-535597 Share on other sites More sharing options...
mommydaddy Posted May 7, 2008 Author Share Posted May 7, 2008 benphp: Good idea. I tried it, and then $_GET['x'] is an empty string. Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/#findComment-535598 Share on other sites More sharing options...
DarkWater Posted May 7, 2008 Share Posted May 7, 2008 I got it....# is what signifies an anchor in a URL, so run urlencode() on asdf#asdf before you put it on the URL, and it'll be http://www.mysite.com/index.php?whatever=asdf%23asdf. Then run urldecode() on the receiving page. Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/#findComment-535599 Share on other sites More sharing options...
mommydaddy Posted May 7, 2008 Author Share Posted May 7, 2008 DarkWater: Excellent work! Thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/#findComment-535603 Share on other sites More sharing options...
DarkWater Posted May 7, 2008 Share Posted May 7, 2008 No problem. =P Quote Link to comment https://forums.phpfreaks.com/topic/104638-_get-question/#findComment-535606 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.