dj-kenpo Posted May 17, 2007 Share Posted May 17, 2007 I know this is a weird question, but bear with me. using $Get_string = $_SERVER['QUERY_STRING']; to receive a query string such as month=may&$day=15&year=2006 so that $Get_string = "month=may&$day=15&year=2006" can I separate the values and turn them into variables? (like a normally would with a url get) $month = "may" $day= "15" etc it would be great to just do $_GET on the url but I'm sending the string as a variable to another script... so i can't just go the easy route. hope this question makes sense thanks, cheers! Link to comment https://forums.phpfreaks.com/topic/51857-solved-breaking-up-the-query-string-dynamicly/ Share on other sites More sharing options...
taith Posted May 17, 2007 Share Posted May 17, 2007 i really dont suggest it... but here http://ca3.php.net/manual/en/function.extract.php Link to comment https://forums.phpfreaks.com/topic/51857-solved-breaking-up-the-query-string-dynamicly/#findComment-255565 Share on other sites More sharing options...
dj-kenpo Posted May 17, 2007 Author Share Posted May 17, 2007 why do you not suggest it? Link to comment https://forums.phpfreaks.com/topic/51857-solved-breaking-up-the-query-string-dynamicly/#findComment-255571 Share on other sites More sharing options...
taith Posted May 17, 2007 Share Posted May 17, 2007 huge security risk... for example... anybody could type in ?month=12&year=2006&security=1|0|1|1... and if you have a $_SESSION[security], it just got changed to 1|0|1|1, and if you use that way of securing... they then can have full access... or whatnot... Link to comment https://forums.phpfreaks.com/topic/51857-solved-breaking-up-the-query-string-dynamicly/#findComment-255574 Share on other sites More sharing options...
dj-kenpo Posted May 17, 2007 Author Share Posted May 17, 2007 ahhh, I see. I just found string parse, so I think that will work. it also seems more secure. do you agree? I think it answers another guys question too... http://ca.php.net/manual/en/function.parse-str.php <?php $str = "first=value&arr[]=foo+bar&arr[]=baz"; parse_str($str); echo $first; // value echo $arr[0]; // foo bar echo $arr[1]; // baz parse_str($str, $output); echo $output['first']; // value echo $output['arr'][0]; // foo bar echo $output['arr'][1]; // baz ?> Link to comment https://forums.phpfreaks.com/topic/51857-solved-breaking-up-the-query-string-dynamicly/#findComment-255578 Share on other sites More sharing options...
kenrbnsn Posted May 17, 2007 Share Posted May 17, 2007 The extract() function is not what the OP needs. The parse_str() function will do what is asked. Ken Link to comment https://forums.phpfreaks.com/topic/51857-solved-breaking-up-the-query-string-dynamicly/#findComment-255582 Share on other sites More sharing options...
dj-kenpo Posted May 17, 2007 Author Share Posted May 17, 2007 I feel like an idiot answering my own question. Link to comment https://forums.phpfreaks.com/topic/51857-solved-breaking-up-the-query-string-dynamicly/#findComment-255585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.