PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi there, all!
Just a supposedly simple question on the header function; I keep on getting the following error in my code:
Cannot modify header information - headers already sent by...
My code is as follows:
I've commented out the echo's above, but my problem clearly lies with the header call. The script is supposed to display a BLOB image from a mySql DB, but I don't understand what I'm doing wrong with the header.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Cannot modify header information - headers already sent by...
the rest of that line should tell you precisely where the error is.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Kindly, that's what I did. I've come across the "whitespace error", but the config.php file contains none. I've looked at various code samples, but would love to know specifically what is wrong with my snippet.
It's pointing to itself, if that makes sense. It's the same file, on exactly the line number the header call appears, and it's also the first time I'm using header.
Ninja, the last couple of links you sent were most helpful! My problem is clearly the fact that I'm new to PHP, and secondly, data being output before my call to header. I shall try and encapsulate my code in a separate .php file (which might work the best as the code runs in a loop), or I might use output buffering.
Just remember all calls to session_start(), header() and setcookie() need to occur before any, yes any, output to the browser. This is a common error with a common solution... don't output anything before calling those function.