Is there a way to put PHP information in the url string that has spaces and special characters?
like this home.php?view=All but Jim's
That won't work...Is there a way to make it work?
Maybe home.php?view="All but Jim's"
Use urlencode(). If you have PHP 5, you can also use http_build_query() (which automatically does a urlencode).
🙂
Cool.
EDIT: use urldecode to decode...Found it.
i used to use some $_GET data that would have spaces in it, never had any issues. let me see if i can find an example for you.
pedlar wrote:i used to use some $_GET data that would have spaces in it, never had any issues. let me see if i can find an example for you.
Don't bother. The correct use is to urlencode() it.
.
EDIT: Please mark this thread as resolved!
mdowling, I made a quick function for you in case you're using PHP 4 and can't use http_build_query().
if (!function_exists('http_build_query')) { function http_build_query ($formdata, $numeric_prefix = '') { $encoded_query = NULL; if (is_array($formdata) && count($formdata) > 0) { foreach($formdata as $key => $value) { $key = ctype_digit((string) $key) ? $numeric_prefix . $key : $key; $encoded_query .= '&' . $key . '=' . urlencode($value); } } return $encoded_query; } }
mdowling wrote: EDIT: use urldecode to decode...Found it.
I just noticed your comment above.
You shouldn't have to decode it when getting values out of $GET. PHP will decode it for you automatically. However, you should know the settings of your 'magic_quotes_gpc' setting before trying stripslashes() on $GET or $_POST values.
Read my post here: http://www.phpbuilder.com/board/showpost.php?p=10648400&postcount=9
Here's a clean values function that will determine whether to do stripslashes() on array values like $GET or $POST: http://www.phpbuilder.com/board/showpost.php?p=10650515&postcount=8
hth.