Warning: Cannot add header information - headers already sent by (output started at /home/tom/sviesoft/login/login.php:8) in /home/tom/sviesoft/login/login.php on line 1000099238
what is wrong?
Printable View
Warning: Cannot add header information - headers already sent by (output started at /home/tom/sviesoft/login/login.php:8) in /home/tom/sviesoft/login/login.php on line 1000099238
what is wrong?
youre probably new to this whole cookie deal ;)
the reason you probably got that error is because you have already written some output data. you have to set a cookie before any " ECHO ''; " or crap like that. did this help ? :)
To sum up what ubunreal69 said a bit clearer..
A cookie has to be set before any output of any kind is made. This includes html, javascript, php echo or print statements, etc.
Example (these will not work):
PHP Code:<html>
<?php setcookie("","","","",""); ?>
Example (these will work):PHP Code:<?php
echo "Text";
setcookie("","","","","");
?>
PHP Code:<?php setcookie("","","","",""); ?>
<html>
PHP Code:<?php
setcookie("","","","","");
echo "Text";
?>
How would you see if a cookie existed?
show us the code?Quote:
Originally posted by prog_tom
Warning: Cannot add header information - headers already sent by (output started at /home/tom/sviesoft/login/login.php:8) in /home/tom/sviesoft/login/login.php on line 1000099238
what is wrong?
Quote:
Originally posted by Gimlin
How would you see if a cookie existed?
PHP Code:if (isset($_COOKIE['variable name']))
echo "The cookie exists with the value of ".$_COOKIE['variable name'];
else
echo "The cookie does not exist."
thanks :cool:
I tried:
doesn't work.PHP Code:<?setcookie("myage","12",time()+600);print "$myage";?>
you may view this file at
http://www.sviesoft.com/beta/cookie.php
you should always set as the path and domain portions of the cookie.
Viewable at http://cpradio.net/cookieTest.phpPHP Code:<?php
setcookie("myage","12",time()+600,"/",$_SERVER['HTTP_HOST']);
if (!isset($_COOKIE['myage']))
echo "Please Refresh the page.";
else
echo $_COOKIE['myage'];
?>
Source Code: http://cpradio.net/cookieTest.phps
we need to see the whole page.Quote:
Originally posted by prog_tom
I tried:
doesn't work.PHP Code:<?setcookie("myage","12",time()+600);print "$myage";?>
you may view this file at
http://www.sviesoft.com/beta/cookie.php
No we don't :pQuote:
Originally posted by phpman
we need to see the whole page.
Just a few quick notes:Quote:
Originally posted by prog_tom
I tried:
PHP Code:<?setcookie("myage","12",time()+600);print "$myage";?>
- According to standards, you should always use "<?php" instead of "<?" You should also never put more than one statement on one line.
- Cookies should be displayed as "$_COOKIE["myage"]" for 4.2 compatability.
- And finally: "Cookies will not become visible until the next loading of a page that the cookie should be visible for." So printing "$myage" would not work until you refreshed.
Matt already covered most of these, but I thought I'd buzz in anyways.
well I thought he was still getting the error. :pQuote:
Originally posted by cpradio
No we don't :p
but it seems that you have taken care of Tom.
It's a very common error, that's why we didn't need to see code.Quote:
Originally posted by phpman
well I thought he was still getting the error. :p
but it seems that you have taken care of Tom.
really, so where was the error?
and tell me if this will produce a header error
that is one file by the way.PHP Code:<?php
$var = "hello";
?>
<?php
setcookie("","","","","");
?>
I love the redundant questions in life :D
This will produce an error, as white space has been created above the setcookie function. PHP only ignores white space inbetween the <?php ?> tagsand this white space was created by the file/html/whatever. (sounds redundant doesn't it :D)Quote:
Originally posted by phpman
really, so where was the error?
and tell me if this will produce a header error
that is one file by the way.PHP Code:<?php
$var = "hello";
?>
<?php
setcookie("","","","","");
?>
Now you can use either of the below instead of what is written above:
PHP Code:<?php
$var = "hello";
?>
<?php
setcookie("","","","","");
?>
PHP Code:<?php
$var = "hello";
setcookie("","","","","");
?>
yes, you are correct Matt, but I was just curious as to how you knew it was something being echoed or just white space. if he was new to this then he would say there is nothing that is being echoed. but it seems that he was talking to somebody behind the scences.
yes it would produce an error and no newbie would now that.
even if he included a file before the setcookie like the code I gave it would produce the same error. that is why I said to show us the code.
100009238+ lines of code?????????? yeah right. I never seen file with that many lines of code.Quote:
in /home/tom/sviesoft/login/login.php on line 1000099238
:confused:
point made :D
I just thought it'd be easier to tell him what was up, then have him post code and point out the individual mistakes.
And just incase anyone cares, it's raining all around my house except in my back yard. Imma go watch it.
That's because most low-level never seen it. Thus you may be one of them.Quote:
100009238+ lines of code?????????? yeah right. I never seen file with that many lines of code.
this cookie **** is driving me insane.
check out:
http://www.sviesoft.com/beta/1.php
everytime I make expiration to time()+600, it just doesn't work, seems like PHP on my server either didn't set up correctly, or it doesn't support time(). It doesn't support $_COOKIES or other crap either, if I use $_COOKIES it gives me $T_VAR or some crap error.PHP Code:<?setcookie("yonghuming","prog_tom",NULL,"","sviesoft.com");
if(isset($yonghuming)){print $yonghuming;}?>
bull**** Tom, don't give me that. even professional programmers don't have pages that long. and you call yourself a high-level programmer? you can't even get a cookie right......Quote:
That's because most low-level never seen it. Thus you may be one of them.
I can almost bet you didn't write it either. let me see the file if it has that many lines in it.....
<?
setcookie("yonghuming","prog_tom", time() +600,"","sviesoft.com");
if(isset($yonghuming)){print $yonghuming;}?>
Did I mention anything as a programmer myself? I wish, someday, to become one, but first I gotta learn from you.
that seems working, but how long do 0 last? forever?PHP Code:setcookie("yonghuming","prog_tom",0,"/","",0);
no cookie can last forever. al you can do is make it last a year I think.
I think if you set it at 0 then it will go away when the browser is closed.
just set time() +43200
setcookie("yonghuming","prog_tom", time() +43200 );
Yeah, cookies always expire, although I think you can make them longer than a year. And yes, it'll expire when the browser closes if it's set to 0.Quote:
Originally posted by phpman
no cookie can last forever. al you can do is make it last a year I think.
I think if you set it at 0 then it will go away when the browser is closed.
just set time() +43200
setcookie("yonghuming","prog_tom", time() +43200 );
My suggestion: set it for a year and renew it each time the user comes to the page.
I have to agree there. 100 million lines (100,009,238) of code is way, way beyond absurd...Quote:
Originally posted by phpman
bull**** Tom, don't give me that. even professional programmers don't have pages that long.
the file is nearly 1.3 TB.
yeah and my dick is 5 miles long,
give me a break Tom :mad:
hmm...how do you fit that on a 120 gig hard drive?Quote:
Originally posted by prog_tom
the file is nearly 1.3 TB.
Yah? and what does it do Tom :rolleyes:
hmmm...does tommy lie alot?Quote:
Originally posted by prog_tom
Warning: Cannot add header information - headers already sent by (output started at /home/tom/sviesoft/login/login.php:8) in /home/tom/sviesoft/login/login.php on line 1000099238
what is wrong?
prog_tom, are you sure the server even supports cookies ? try a simple bit of code to just test it first.
simple test:PHP Code:setcookie("greeting","elooo", time()+3600);
IF (isset($_COOKIE['greeting']))
{ECHO 'cookie value is', $_COOKIE['greeting'];}
Good catchQuote:
Originally posted by The Hobo
hmmm...does tommy lie alot?
That won't work. Cookies aren't accessable until it is reloaded. Cookies won't appear until the script that set them is refreshed.Quote:
Originally posted by ubunreal69
prog_tom, are you sure the server even supports cookies ? try a simple bit of code to just test it first.
simple test:PHP Code:setcookie("greeting","elooo", time()+3600);
IF (isset($_COOKIE['greeting']))
{ECHO 'cookie value is', $_COOKIE['greeting'];}
let me re-phrase it then :pQuote:
Originally posted by The Hobo
That won't work. Cookies aren't accessable until it is reloaded. Cookies won't appear until the script that set them is refreshed.
put:run the page, then refresh it.PHP Code:setcookie("greeting","elooo", time()+3600);
IF (isset($_COOKIE['greeting']))
{ECHO 'cookie value is', $_COOKIE['greeting'];}
:D
Yo! My first post...
Er, don't mean to critiscise anyone, but who cares about not putting each statement on a new line?!
I certaintly don't - that's what the ";" closing character is for!!!
And jeez, all that unnecessary whitespace! Pah...
You can make pages verbose, without using stupid format conventions that take up space! After all, why format the formatting code...? (such as HTML - but applies to PHP,VBScript,Javascript, etc.)
P.S: A 1.3+ Terrabyte script?! I wonder how long that imaginary file would take to execute on the server... lol yeah, right...
Employers? I know people who have been told they didn't get the job because of things like that. The employer looks at your work and see's a confusing mess, he's going to hand you a candy cane and tell you to go home.Quote:
Originally posted by trojjer
Er, don't mean to critiscise anyone, but who cares about not putting each statement on a new line?!
So if you every want a job, you should care. If you're just going to make piss-ass programs for the rest of your life, feel free.
dude I don't believe you just said that. I would hate to see your code.Quote:
Originally posted by trojjer
Yo! My first post...
Er, don't mean to critiscise anyone, but who cares about not putting each statement on a new line?!
I certaintly don't - that's what the ";" closing character is for!!!
And jeez, all that unnecessary whitespace! Pah...
You can make pages verbose, without using stupid format conventions that take up space! After all, why format the formatting code...? (such as HTML - but applies to PHP,VBScript,Javascript, etc.)
fjdksa fl;sdlthisjg dfksajf dkisdfjska l;fjd sakl;onej gdsfkalf;jdksla ;longfj dskalfj;d skal;linefjdksafj dskla;
can you tell what that line just said? no I bet you can't, give me a break will ya. it's only human to make it so it is readable.
suppose you made that 1.3 TB file for Tom huh? :rolleyes:
That script would take more than 24 hours to lead from a server, It'll probablt make the server crash with that many lines and we all know you're lieing so shut the **** up and leard how to set a cookie!!! END OF DISCUSSION!, PS. You're a retard ;)
heh, it worked:)
wow, 5 miles. we can walk on it.
i love to write code in one line or 2 with no spaces, ; between them, that way, no one would peek it.