Helpful Information
 
 
Category: MySQL and other databases
any thoughts on this error?

here is the function the error says this is wrong


function NoCache() {
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
}

then i call this later


NoCache();

here is the include file it is asking about. check linked file
thankx for the help

here is the function the error says this is wrongWhat error? I see no error.

currently there is no error showing becasue i have commented it out.
does anything look bad in the way that function is written?

Not obviously so, no. Why don't you post the error so we can see what the problem is?

Warning: Cannot modify header information - headers already sent by (output started at /home/content/e/j/l/ejlcustomgolf/html/eventCalendar.php:8) in /home/content/e/j/l/ejlcustomgolf/html/_admin/includes.php on line 14

Warning: Cannot modify header information - headers already sent by (output started at /home/content/e/j/l/ejlcustomgolf/html/eventCalendar.php:8) in /home/content/e/j/l/ejlcustomgolf/html/_admin/includes.php on line 15

Warning: Cannot modify header information - headers already sent by (output started at /home/content/e/j/l/ejlcustomgolf/html/eventCalendar.php:8) in /home/content/e/j/l/ejlcustomgolf/html/_admin/includes.php on line 16

Warning: Cannot modify header information - headers already sent by (output started at /home/content/e/j/l/ejlcustomgolf/html/eventCalendar.php:8) in /home/content/e/j/l/ejlcustomgolf/html/_admin/includes.php on line 17

Warning: Cannot modify header information - headers already sent by (output started at /home/content/e/j/l/ejlcustomgolf/html/eventCalendar.php:8) in /home/content/e/j/l/ejlcustomgolf/html/_admin/includes.php on line 18

posted-

As I suspected.
There's nothing wrong with the function; the problem is that you're calling it after HTML has already been sent to the browser. header (http://www.php.net/header)() can only be called before any other output is sent to the browser.

so i need to move it where?
thankx twey for the help

Simplest place is right at the beginning of the page, and make sure there is nothing before the opening <?php tag; that includes whitespace.

Great, Twey thankx for your continued help in the forums.

Or you just start your PHP Script with this:

<?php
ob_start();
and end it with this:

ob_end_flush();
?>

Or you just start your PHP Script with this:

<?php
ob_start();
and end it with this:

ob_end_flush();
?>
You don't want to do that unless you have to. It will slow down the script.

[Using output buffering] You don't want to do that unless you have to. It will slow down the script.I would disagree with that statement for three reasons (though it's not necessarily an exhaustive list):


By buffering data, the preprocessor can send data to the server in large segments, rather than piecemeal.
Output buffering allows filters to be applied that might not otherwise be possible. An obvious example is compression. Though it's not necessary to compress output, the benefits typically outweigh any possible performance penalty.
Output buffering provides the opportunity for the script to determine the content length and set the corresponding Content-Length header. Without this header, the connection must be closed in order to signal the end of the entity. Any further requests must establish another connection, rather than using persistent connections defined by HTTP/1.1.

If anything, the use of output buffering should be common practice, not something to avoid. In fact, output buffering is enabled by default in the recommended configuration to accumulate writes into 4kB chunks.

Mike

In the case of using it to avoid having to correctly place header() calls, however, it could lead to difficult-to-read code, so I would not recommend using it for expressly this purpose.

In the case of using it to avoid having to correctly place header() calls, however, it could lead to difficult-to-read code, so I would not recommend using it for expressly this purpose.Surely that's an issue of code design though, not output buffering itself. Of course, if simple language constructs permit the correct and timely sending of HTTP headers then there's no point of explicitly introducing buffering, but the same can be said in any instance where something is used without any tangible benefits.

Mike

Indeed so. That's what I was trying to point out: that abusing output buffers in this way would likely lead to poor code design.

Ok,I'm confused.I thought output buffering would slow things down because I read this in the php.ini filer.

; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions.

but early it says this

; - output_buffering = 4096 [Performance]
; Set a 4KB output buffer. Enabling output buffering typically results in less
; writes, and sometimes less packets sent on the wire, which can often lead to
; better performance. The gain this directive actually yields greatly depends
; on which Web server you're working with, and what kind of scripts you're using.

So is output buffering faster or slower? :confused:

In 90% of cases, faster. Read mwinter's post.










privacy (GDPR)