Closed ghost closed 10 years ago
Turning on error reporting gives this message.
Warning: Cannot modify header information - headers already sent by (output started at /home/.../functions/data.php:45) in /home/.../config/setup.php on line 28
Yup. The header();
function will not work if anything is sent to the browser prior to it. I mean ANYTHING. Now that doesn't mean you cannot have php code in your setup.php file prior to running header();
. However if anything that would be displayed in the browser is sent, it will fail.
So no echo
statements and things like that. Most likely, though, the culprit is probably a rouge space somewhere.
So between the top of setup.php and the line where you run the header();
function, look on every line for a blank space. One way to do it is to highlight all the lines and see if there is a space character in there.
Tabs are perfectly fine as long as it is an actual tab. So for instance, if your tab key pushes you out for spaces from the left of the document, that is perfectly fine. However, if instead, you hit the space key 4 times to achieve that tab you will get an error.
Places to look would be:
1 At the beginning of a blank line. 2 Before a php statement. 3 At the end of a php statement.
Here are some examples... (this comment box wont allow me to give you an example of the first one)
Example of 2: click and drag just before the statement to highlight the space character
$spacebefore = 'the php statement';
Example of 3: click and drag just after the statement to highlight the space character
$spacebefore = 'the php statement';
Hope this helps! ~Alan
Yes! Thanks man, that solved the problem, although it took me another half hour of trawling through my code finding spaces.
When I press save in Aptana occasionally the upload fails, and you can't click save to upload again without modifying the code. I've gotten into the habit of adding a random space to my code to allow me to save again - guess they've come back to haunt me, although I wasn't aware that the spaces could do any damage. Let this be a warning to others....
Just want to say I really appreciate the effort you're putting in to making these videos. I've learnt so much in such a short space of time. Keep it up!
The following doesn't work. Navigating to the base url leaves me facing a blank page.
header('location: home');
Any ideas?