Here the production system is Linux based and the development system is Windows based, hence the code has the following problem, what should be done to get the code to work on the Windows system.

The Linux machine runs php-4.3.2-8.ent and the windows machine runs php 5.2.6. on the Linux machine the gyform1.php runs fine, but on windows it crashes with header error and warnings. However if you add line 9 (ob_start();) as in gyform1-win and remark line 25-27

/*HEADER("Expires: time()");
HEADER("Pragma: no-cache");
HEADER("cache-control: no-cache, no-store, must-revalidate")*/

the code runs fine on the windows system. What is be the problem?
here I have attached those php files. Someone please answer me!!

Recommended Answers

All 4 Replies

Your headers are invalid. Don't forget the function names are case sensitive. So turn HEADER() to header() like the following.

header("Expires: time()");
header("Pragma: no-cache");
header("cache-control: no-cache, no-store, must-revalidate");

But I'm not sure about those strings inside the header though.

Yes, cwarn23 is right all the php functions are in lowercase letters and also one more thing, even though it is a bad practice of using ob_start(), If you are facing "headers can not send problem" use ob_start() and at the end of the page use ob_flush().

If you want to solve the error with out using the functions(ob_start() and ob_flush()), start session always at the top of the page, and there should bot be any spaces at the starting of the page and at the ending of the page.

after using header function avoid echoing of data.

Guys thanx for ur answers........
but still I need to know that why its not wroking on windows (gyform1.php) which works properly on linux. However if you add (ob_start() as in gyform1-win and remark that

/*HEADER("Expires: time()");
HEADER("Pragma: no-cache");
HEADER("cache-control: no-cache, no-store, must-revalidate")*/

the code runs fine on the windows system. Y is that ?
(this is an exam question and thats y I need answers seriously)

Can you remove the ob_start() and remove the headers then tell me any errors that are popping up. Because an E_Notice error could make the headers fail.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.