Sorry, I don’t know what you are asking. What do you want the count variable to do, where are you going to use it? In your code above, you just increment it, then re-set it to zero inside your if clauses.
If I put just that script into a html file, it relocates as you want it to. So the answer must lie in whatever else is going on in that code. Your count issue will stop it even trying to relocate, but I don’t understand why it doesn’t display the error alert.
O/T but you might want to be a bit more consistent - both of your script opening tags are introducing JS code, but you specify it differently for each one. I don’t know if it makes any difference.
i tried this wont work
What does “won’t work” mean? You need to give a bit more information.
Is it just the parse error for when you have an extra close brace?
no erros it goes all the time on same page
If I execute the code as you posted it, I get:
( ! ) Parse error: syntax error, unexpected '}' in C:\wamp\www\sitepoint\jsrelocate.php on line 20
I don’t know why you don’t.
If I edit the code to remove the spurious close brace, it redirects as you expect it. I can’t think of any reasons why it’s not doing the same for you, so I don’t think I can offer anything else here. Hope you find out what was causing it.