Please Help!!

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!

Moderator: General Moderators

Post Reply
veneerz
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:57 pm

Please Help!!

Post by veneerz »

Hello,
My programmer is on vacation and this mourning I woke up and our shop is giving this error.

Warning: Cannot send session cookie - headers already sent by (output started at /home/www/veneerz/setup.php:1032) in /home/www/veneerz/shop.php on line 4

Warning: Cannot send session cache limiter - headers already sent (output started at /home/www/veneerz/setup.php:1032) in /home/www/veneerz/shop.php on line 4

Our server recently switched to PHP 4.2.2 and the site was written for an older version 4.0.1 I think. May this be a reason for a conflict?
Please if anyone knows head me in the right direction to where to look for an error. I am not a PHP expert but I am a fast learner and almost sure that can fix this bug if at least know what exactly causes it.
Here are the 4 lines from shop.php:

<?php
include("setup.php");

session_cache_limiter('private');

session_start();
DSM
Forum Contributor
Posts: 101
Joined: Thu May 02, 2002 11:51 am
Location: New Mexico, USA

Post by DSM »

session_start(); needs to be at the very top

Code: Select all

&lt;?php
session_start();
include("setup.php"); 
session_cache_limiter('private'); 
?&gt;
veneerz
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:57 pm

Post by veneerz »

Thank you DSM.
I changed the order. but now a new error comes up:

Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition cart_items of the object you are trying to operate on was loaded _before_ the session was started in /home/www/veneerz/setup.php on line 465

8O
DSM
Forum Contributor
Posts: 101
Joined: Thu May 02, 2002 11:51 am
Location: New Mexico, USA

Post by DSM »

hmm, it obviously has to have the set.php included before the session starts, but you cannot start a session after HTML has been output to the browser.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Change the order to

Code: Select all

&lt;?php
include("setup.php");  
session_start(); 
session_cache_limiter('private');  
?&gt;
veneerz
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:57 pm

Post by veneerz »

When UI chenged the order again, here is how the error come up:

Warning: Cannot send session cookie - headers already sent by (output started at /home/www/veneerz/setup.php:1032) in /home/www/veneerz/shop.php on line 4

Warning: Cannot send session cache limiter - headers already sent (output started at /home/www/veneerz/setup.php:1032) in /home/www/veneerz/shop.php on line 4

I am lost an in the dark. This is really getting depressing. On Monday we most likely will get fired. Please let me know how to fix this bug. Bogdan will only come back on Wednesday, but our boss will be back on Monday and would like to see how all of our sites are doing. There is no way I can contact Bogdan.... his butt is partying in Florida. I hope this tropical storm will rip off the roof of his bungalow while he's sleeping.
The only language I know is ActionScript, for gods sake, I am only a designer!
I will pay for this forum's next 3 month server bill, just please help me fix this before Monday 9am EST. I am really back against the ropes here.

Art
Still brathing for now.
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post by dusty »

check out the first sticky..

Code: Select all

&lt;?
ob_start();
include("setup.php");   
session_start();  
session_cache_limiter('private');   
ob_end_flush();
?&gt;
veneerz
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:57 pm

Post by veneerz »

It worked, it worked!!!!!!!!!!
I love you dusty!!!!
And the rest of you guys, you were really helpful!!!!!
Is there a way to donate to this forum?????
Place like this should really be kept sacred and cared for. I had never seen support like this even from our web hosts!!!!
I really want to do something nice for you guys.
If anyone wants a dash kit, I will get it for them for 30% off our prices that is what our company pays for them.
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post by dusty »

i don't have a forum but you can pay my bills :D
veneerz
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:57 pm

Post by veneerz »

dusty, can you run a forum???
I can supply great audience.....
It will be an automotive forum and if we run it properly, advertisements can be really rewarding...
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Anyone can run a forum try phpBB or vBulletin!

So what does ob_start do?
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post by MattF »

It starts output buffering so that anything echo'ed is not echo'ed but is saved temporarily until output buffering is stopped. The only concern I have is that there may be some error occuring that was being echo'ed above session start and now this is hidden so something may not be working right without you knowing. On the other hand it could just be a warning or something.
veneerz
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:57 pm

Post by veneerz »

Hey guys,
There is one problem with ob_start ();
It flushes the session if you go to a different page. For example, if someone put an item in the basket and then decides to browse some more before submiting and order and leaves the shop.php page session is flushed and when he/she comes back to check out the item is gone from the basket......
But I guess I can live with this for a couple of days.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Well what is in setup.php anyway?
veneerz
Forum Newbie
Posts: 8
Joined: Fri Sep 13, 2002 5:57 pm

Post by veneerz »

You want me to post an entire 40k file?
Post Reply