
![]() |
jammaster82
wtf?
What am I doing wrong here does this work for anybody, ive tried it on two separate public phpservers:<? phpsetcookie('user','johnny',time()-3600); ?> Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/webmaste/thesite.com/test. php:2) in /hsphere/local/home/webmaste/thesite.com/test.phpon line 3perkiset
You almost certainly have at least one carriage return OUTSIDE of the <?
phpand ?> markers... if that is the case, then the carriage return will be output immediately and since (some) output has been sent, you can no longer send your headers.That one got me bad for a while when I was first starting, and was single handidly the reason for why I code with 100% ZERO html-plus- phpstyle - it's all purePHPstyle with blocks of HTML.Here's what I mean: WRONG way to code: <html> <body> The date is: <? phpecho date('m/d/Y', time()); ?></body> </html> The RIGHT way to code: <? php$theDate = date('m/d/Y', time()); echo <<<HTML <html> <body> The date is $theDate </body> </html> HTML; ?> Note that the phpfile ends immediately after the ?> in the second example, although I THINK that you'd still be ok if there is one return after it and no more./p jammaster82
gotcha on the blocks... love it.
<? phpsetcookie('user','johnny',time()-3600); ?>no carriage return or line feed at end.. so that should work then right? perkiset
Yepper... unless you got other code involved that I cannot see here.
There might also be something in your PHPinstance that is sending stuff back early - I don't remember what, but I wanna say I say a thread somewhere about a problem like that... something about the header() function and stuff already being sent byPHP... if it don't woik as is then ping back and we can look...jammaster82
Woah, I have no idea why my brains dont
work any more, when i actually refresh it does work on both servers.... ![]() The japanese have this thing called the mitsu no kokuro... which means that the mind should be still and calm like a lonely pond. But what happens when the big kids come around and THROW GIANT ROCKS IN IT AND ALL THE FISH START SCREAMING THAT A SINGLE CHARACTER TOOK AN HOUR AND A HALF OF YOUR FIRST DAY AS A PHPPROGRAMMER AWAY FROM YOU ANDITS GONNA BE POSTED ON GOOGLE FOREVER THAT YOU ARE A DUMBASS.... THEN WHAT?!?!?! THEN WHAT>!>!??!?!?!?! ![]() center early tonight so ill be loggin off soon. ratthing
I hear you JM, I hear you.
What's worse--you *think* the program/server config/etc is working, get it all fixed up and moved to production, and the new bits don't work. You think, "WTF, over?" You go back and look at development, and ![]() It always happens, it just happens for different bits the further along you get on the curve. |

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads