LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-08-2006, 06:54 AM   #1
baddah
Member
 
Registered: Feb 2006
Location: Cape Town,South Africa
Distribution: Fedora Core 8
Posts: 183

Rep: Reputation: 30
PHP header("Location: xxx.php") not working?


Hi,I have the following code in a php script

header("Location: xxx.php");

where xxx is a another script in the same folder.for some reason,the browser does nothing when its suppose to redirect to the script.I'm using FireFox,is there any known bugs with FireFox and header function?I read somewhere to use ' ' instead of " ",but still it did nothing.This is really irritating me a bit,so any help will be appreciated.thanks
 
Old 05-08-2006, 07:53 AM   #2
Spudley
Member
 
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299

Rep: Reputation: 32
Has your script output anything else prior to calling the header() command?

If you've output anything at all (even just the <html> tag), you can't call header(). Even if you think you haven't, one thing to check is that your script doesn't start with a blank line. Also, if you've got any includes, make sure they don't have any blank lines before or after the <? and ?> tags. That's caught me out before.

Finally, if you're not getting anything at all on the browser, have a look at your PHP config, and see whether it's supressing error messages. If you turn your error messages on, you might find it tells you something meaningful instead of just showing a blank page.

Hope that helps
 
Old 05-08-2006, 08:37 AM   #3
baddah
Member
 
Registered: Feb 2006
Location: Cape Town,South Africa
Distribution: Fedora Core 8
Posts: 183

Original Poster
Rep: Reputation: 30
o ok,i didn't know that.but i need to output some stuff,so i guess i'll have to use something <meta http-equiv="refresh" content="0; url=xxx.php>?I used to have this in my code but then some strange stuff happened,the browser kept refreshing as if it was in some endless loop,but anyway i'll try to use the <meta.. and get that working.thanks
 
Old 05-08-2006, 05:16 PM   #4
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 198

Rep: Reputation: 30
If you need to output something before redirection, simply use JavaScript to redirect :

<script>
window.location.href='blabla.html';
</script>

As Spudley wrote, header must be the very first thing of your script's output and even a single newline or space can screw it up.
 
Old 05-09-2006, 01:46 AM   #5
baddah
Member
 
Registered: Feb 2006
Location: Cape Town,South Africa
Distribution: Fedora Core 8
Posts: 183

Original Poster
Rep: Reputation: 30
thanks the javascript method worked,but i'd rather use meta tags.i've read somewhere that meta tags should also be used between the <head></head> tags,but i put the meta tags inside the <body> part and it seems to work.should this be fine?,to use the meta inside <body>?.my html skills not really very good,so sorry for all the questions.
 
Old 05-09-2006, 09:50 AM   #6
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 198

Rep: Reputation: 30
Meta tags are not supposed to be put insde of the body part. They belong to the head... Alhough it might worked for you from the body it's not gonna work in all the browsers and most likely will produce some errors. The proper way to do it is to use JS. I don't know why you don't want to use JS. Do you need a timeout? If so, then use setInterval function.
 
Old 05-10-2006, 01:51 AM   #7
baddah
Member
 
Registered: Feb 2006
Location: Cape Town,South Africa
Distribution: Fedora Core 8
Posts: 183

Original Poster
Rep: Reputation: 30
thanks,looks like its working fine.used JS rather.not to sure yet on how to delay the redirect yet,but I'm sure i'll figure it out.
 
Old 05-10-2006, 09:00 AM   #8
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 198

Rep: Reputation: 30
Sorry, I put the wrong function name there, it should be setTimeout not setInterval. setInterval calls the given function periodically.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Error, some other host already uses address XXX.XXX.XXX.XXX" mwbb_support Linux - Networking 5 01-20-2014 08:59 AM
Incorrect PHP code is working, shoud I "fix" it? rblampain Programming 6 04-28-2006 10:33 PM
Location of the directory of "C" header files RoMan65 Linux - Software 8 01-19-2006 04:59 PM
PHP / VideoLAN / Fedora Core Question - how can I get the PHP "exec" function to work gtrawoger Linux - Software 3 12-21-2005 06:51 AM
PHP header("Location") Gerardoj Programming 1 05-11-2004 04:29 PM


All times are GMT -5. The time now is 10:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration