Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Semi colon affecting redirect function

Status
Not open for further replies.

ralphiooo

Programmer
Oct 23, 2005
64
GB
Hi, i'm trying to do a simple redirect problem but i've run into a problem, here's the function:

function redirect($path, $timeout = 2) {
header('Refresh: ' . $timeout . '; URL=' . str_replace('&', '&', $path));
}

My problem is when the path passed in contains & ie (index.php?s=1&c=2) it cuts off everything after the semi colon. I tried doing a str_replace on the path replacing & with & but i found that this doesn't always works when you go to a path with & instead of &.
 
You do not use & server-side for URLs... so you are right to be replacing all occurrances of & with a single & character.
...i found that this doesn't always work...
Your code looks acceptable - could you provide us with an example that "doesn't always work" please.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Hi, cheers after looking into it further i realized my edit statement was resetting the category id and not the sub category id therefore the redirect went to the wrong place. Cheers again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top