[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 07-01-2005, 06:54 AM   #1 (permalink)
Senior Member
 
Porte's Avatar
 
Join Date: May 2005
Location: Somewhere on earth!
Posts: 3,528
21.30 NP$ (Donate)

Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of


What's wrong with session_start()?

Hello,

This is the code :

<? session_start(); ?>

When I access this page it gives :

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /mnt/storage/users/c/u/s/customcoding/index.php:1) in /mnt/storage/users/c/u/s/customcoding/index.php on line 1

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /mnt/storage/users/c/u/s/customcoding/index.php:1) in /mnt/storage/users/c/u/s/customcoding/index.php on line 1


To tell you the truth, I'm amazed with the results

How can I avoid this ugly error?

I believe I shouldn't see it...
Porte is offline  
Old 07-01-2005, 07:36 AM   #2 (permalink)
An American Soldier
 
-Ray-'s Avatar
 
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,630
2.53 NP$ (Donate)

-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold


Output buffering is turned off. Contact your webhost and ask him to turn it off.

Or you can use the ob_start (); command which will buffer the headers for you.

Your Best Friend
-------------------------
http://us4.php.net/ob_start
__________________
Completely Free cPanel Hosting
-- Deployed to Afghanistan --
"There is no such thing as rich over-night unless you owned Google stock in 2006"
-Ray- is offline  
Old 07-01-2005, 07:45 AM   #3 (permalink)
Senior Member
 
Porte's Avatar
 
Join Date: May 2005
Location: Somewhere on earth!
Posts: 3,528
21.30 NP$ (Donate)

Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of


Hello, can you direct me into using ob_start() correctly, I just never used the ob functions. Can you give me a sample code?

I tried to put ob_start() above session_start() but nothing.

I do not know if this is a resolution to my current host or not.. I just added
error_reporting(0);
before
session_start();

Correct me please.
Porte is offline  
Old 07-01-2005, 08:08 AM   #4 (permalink)
An American Soldier
 
-Ray-'s Avatar
 
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,630
2.53 NP$ (Donate)

-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold


Put ob_start() start above the session_start()

after ob_start(); use ob_getcontents(); (i think)

after that use ob_printcontents(); (think again)

then ob_end()

i think they are the right ones, the content ones, check in that outpout buffering link i gave you
__________________
Completely Free cPanel Hosting
-- Deployed to Afghanistan --
"There is no such thing as rich over-night unless you owned Google stock in 2006"
-Ray- is offline  
Old 07-01-2005, 08:15 AM   #5 (permalink)
Senior Member
 
Porte's Avatar
 
Join Date: May 2005
Location: Somewhere on earth!
Posts: 3,528
21.30 NP$ (Donate)

Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of


let me check, thanks!

Doesn't work now when I try to use header somewhere it says

Warning: Cannot modify header information - headers already sent by (output started at /home/designpo/public_html/index.php:1) in /home/designpo/public_html/includes/account_info.php on line 6
Porte is offline  
Old 07-01-2005, 10:46 AM   #6 (permalink)
An American Soldier
 
-Ray-'s Avatar
 
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,630
2.53 NP$ (Donate)

-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold


then u reuse the ob start command..

The easiest thing to do is contact your web host and ask him to turn on php output buffering.

If u need a host that has it on. read my sig!
__________________
Completely Free cPanel Hosting
-- Deployed to Afghanistan --
"There is no such thing as rich over-night unless you owned Google stock in 2006"
-Ray- is offline  
Old 07-01-2005, 10:52 AM   #7 (permalink)
Senior Member
 
Porte's Avatar
 
Join Date: May 2005
Location: Somewhere on earth!
Posts: 3,528
21.30 NP$ (Donate)

Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of


If you accept credit cards globally, I could sign up..otherwise, no pp support
Porte is offline  
Old 07-01-2005, 11:33 AM   #8 (permalink)
An American Soldier
 
-Ray-'s Avatar
 
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,630
2.53 NP$ (Donate)

-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold-Ray- is a splendid one to behold


check ur pms
__________________
Completely Free cPanel Hosting
-- Deployed to Afghanistan --
"There is no such thing as rich over-night unless you owned Google stock in 2006"
-Ray- is offline  
Old 07-01-2005, 11:30 PM   #9 (permalink)
New Member
 
Join Date: Jul 2005
Posts: 8
12.00 NP$ (Donate)

val539 is an unknown quantity at this point


PHP Code:
<? @session_start(); ?>
or for more security script:

PHP Code:
<? ignore_user_abort(1); error_reporting(0);  session_start(); ?>
Regards
val539 is offline  
Old 07-02-2005, 02:36 AM   #10 (permalink)
Pro Coder & Designer
 
xlusive's Avatar
 
Join Date: Apr 2005
Location: Netherlands
Posts: 964
101.50 NP$ (Donate)

xlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nice


i think this has been fixed . he found a good host now i guess :P
__________________
Online Dragonball Game
xlusive is offline  
Old 07-02-2005, 04:30 AM   #11 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
in my opinion using output buffering certainly is not the best solution, he would be best finding what is causing the error in the first place.
Peter is offline  
Old 07-02-2005, 05:53 AM   #12 (permalink)
Senior Member
 
Porte's Avatar
 
Join Date: May 2005
Location: Somewhere on earth!
Posts: 3,528
21.30 NP$ (Donate)

Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of


Yea, it's been fixed now as xlusive said.. it was something with the host, that output buffering is Off, which globally turns off all session_start() usage.

Thanks though;
Ahmed
Porte is offline  
Old 07-02-2005, 09:41 AM   #13 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
as far as I am aware output buffering has nothing to do with sessions (and nothing is mentioned in the php manual). The reason the script failed in the first place was because the script output to the browser BEFORE session was started (even a space output causes this error).

The way you have fixed the problem is just a quick and dirty way to go about it and not actually fixing the problem itself.
Peter is offline  
Old 07-02-2005, 10:22 AM   #14 (permalink)
Senior Member
 
Porte's Avatar
 
Join Date: May 2005
Location: Somewhere on earth!
Posts: 3,528
21.30 NP$ (Donate)

Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of


Ok it's a dirty way, and I like it.. anymore comments?
__________________
Custom WordPress theme design. Top notch free WordPress themes
Custom Theme Design
Porte is offline  
Old 07-02-2005, 05:39 PM   #15 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
just offering advise thats all, that is what you asked for
Peter is offline  
Old 07-08-2005, 09:02 PM   #16 (permalink)
NamePros Member
 
Join Date: Oct 2003
Posts: 126
251.90 NP$ (Donate)

i386 is an unknown quantity at this point


If you used this code, then it'll error out:

<html>
BLAH...
<?php
session_start();
?>

What I use:

Code:
<?php
session_start();

echo <<<ENDDOC
MY DOCUMENT HERE
ENDDOC;

?>
i386 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Meta-tags wrong? FastIcon.com Marketing Techniques 5 10-27-2004 11:43 AM
Push to Wrong Account... What can be done? Jeanco Domain Name Discussion 7 12-28-2003 06:43 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 04:14 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85