The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 16, 2019, 11:13:54 PM

Login with username, password and session length


Pages: [1] 2
  Print  
Author Topic: Cannot modify header information  (Read 5760 times)
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« on: January 05, 2008, 01:32:40 PM »

wtf?

What am I doing wrong here does this work
for anybody, ive tried it on two separate
public php servers:

<?php
setcookie('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.php on line 3
« Last Edit: January 05, 2008, 01:37:20 PM by jammaster82 » Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: January 05, 2008, 01:43:00 PM »

You almost certainly have at least one carriage return OUTSIDE of the <?php and ?> 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-php style - it's all pure PHP style with blocks of HTML.

Here's what I mean:

WRONG way to code:
Code:
<html>
<body>
The date is: <?php echo date('m/d/Y'time()); ?>
</body>
</html>

The RIGHT way to code:
Code:
<?php

$theDate 
date('m/d/Y'time());
echo <<<HTML
<html>
<body>
The date is 
$theDate
</body>
</html>
HTML;

?>


Note that the php file 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
« Last Edit: January 05, 2008, 01:46:57 PM by perkiset » Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« Reply #2 on: January 05, 2008, 01:53:21 PM »

gotcha on the blocks... love it.

<?php setcookie('user','johnny',time()-3600); ?>

no carriage return or line feed at end..

so that should work then right?

« Last Edit: January 05, 2008, 01:56:04 PM by jammaster82 » Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #3 on: January 05, 2008, 02:03:18 PM »

Yepper... unless you got other code involved that I cannot see here.

There might also be something in your PHP instance 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 by PHP... if it don't woik as is then ping back and we can look...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« Reply #4 on: January 05, 2008, 02:31:50 PM »

Woah, I have no idea why my brains dont
work any more, when i actually refresh
it does work on both servers....

 Nerd

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 PHP PROGRAMMER AWAY FROM YOU AND
ITS GONNA BE POSTED ON GOOGLE FOREVER
THAT YOU ARE A DUMBASS.... THEN WHAT?!?!?!

       THEN WHAT>!>!??!?!?!?!


 Praise  thank you. they want me back at the
center early tonight so ill be loggin off soon.
« Last Edit: January 05, 2008, 02:33:42 PM by jammaster82 » Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
ratthing
Journeyman
***
Offline Offline

Posts: 75


View Profile
« Reply #5 on: January 05, 2008, 04:28:42 PM »

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 D'oh! you forgot about X thing in place on development, so of course the new bits worked there.

It always happens, it just happens for different bits the further along you get on the learning curve.

=RT=
Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #6 on: January 05, 2008, 05:02:18 PM »

JM you must certainly remember my deep and unabiding respect for Murphy in these instances. It's probably completely unchanged, but the Universe simply didn't want it to go that easily for you yet.

Deep and unabiding respect, let me tell you.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
ratthing
Journeyman
***
Offline Offline

Posts: 75


View Profile
« Reply #7 on: January 05, 2008, 05:16:57 PM »

JM you must certainly remember my deep and unabiding respect for Murphy in these instances. It's probably completely unchanged, but the Universe simply didn't want it to go that easily for you yet.

Deep and unabiding respect, let me tell you.
It's essential to make the proper sacrifices (like cutting yourself and bleeding on your server case) to whatever computer ghods are overseeing your area, or to put up wardings against evil spirits.  I have a very ugly Dia De Los Muertos mask I hang up by my desk at every new job (hmmm...I guess that means I should hang it up here at home...preventative medicine is best).

Murphy is a mean bastige.
=RT=
Logged
dink
Expert
****
Offline Offline

Posts: 349


View Profile
« Reply #8 on: January 05, 2008, 05:53:48 PM »

There is nothing in the world so cool as having some piece-of-shit code string actually run as you wanted it to do.  Especially after having spent countless hours trying different things/ways.

My expectations have changed a lot.  Nowadays I expect to find empty arrays and vars full of unintelligible mush.  I have error reporting set to "get all of it and print it out right here so's every whore can read it".  Most times the error reporting contains more bytes than the script did.   ROFLMAO

I was so very proud last night.  A small script that I have been working on (fruitlessly) for some time, actually got past the fatal error stage.  When I gathered up the results, my joy diminished to a very small smirk.  The returned data wasn't anything like it was supposed to look.  Ah well, the thrill of learning something new.{sux rawr egos}
Logged

[quote Nutballs]
the universe has a giant fist, and its got enough whoop ass for everyone.
[/quote]
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« Reply #9 on: January 07, 2008, 01:17:34 PM »


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-php style - it's all pure PHP style with blocks of HTML.


Yeah... now i can think... thats why i never liked
ColdFusion, it was like the WRONG way you mentioned,
so it ends up being this monolithic monstrous self referencing
loop  Vomit nightmare...

makes me want to (in pseudocode for lack of knowing php yet..)

<?
require "genericlogindatabasesitehandler.php";

$outstr=fileread(somehtmlaclientwantstowrapthingsaroundthathehasplantedmyvarlist in);

echo <<<HTML
$outstr
HTML;

?>


and then just make a generic login database
and just do this TDereferencer/RB4 style...

and then publish some list of vars to the client

$thetableweagreedoncontainingtheproductslistedver121a
$thedate
$thecompanyname
$thecompanyfonenum
$etc..

then he can do all the design for the site
and i can just change a few things when i get
a new client hahaha
« Last Edit: January 07, 2008, 01:42:38 PM by jammaster82 » Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #10 on: January 07, 2008, 02:51:15 PM »

You'll get there.

I have a deligthful suite of that sort of component/objects that allows me to build really sophisticated stuff in tiny amounts of time. You'll see soon - you think the right way.

/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« Reply #11 on: January 07, 2008, 08:21:35 PM »

themessage := '                               I still find use of that thinking,'
outstr := deref('&themessage'+' even today at '+FormatDateTime('hh:mm:ss',now())+'....   ')
consoleoutput(AllTrim(outstr))
terminaloutput('=JM=')
« Last Edit: January 07, 2008, 08:25:50 PM by jammaster82 » Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #12 on: January 07, 2008, 11:13:19 PM »

Do you still actually have one of my robot interpreters running?  Shocked
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
jammaster82
Lifer
*****
Offline Offline

Posts: 666


Thats craigs list for ya


View Profile
« Reply #13 on: January 08, 2008, 09:54:07 AM »

I still have it!  I actually used it to write an eight line program
to insert these huge sql files i have into the ms sql server...
i had it chew up the entire bible out of a text database and
turn it into sql statements then execute them ten by ten,
throwing exceptions into a seperate TStringlist.... beat
the hell out of doing it by hand!!

I made a speedreader bot with it last summer too, pasted
some stuff in it i want to read and Consolefontsize := big
and it flashes the words one at a time in the same place on
the screen youd be surprised at what you can retain just
pasting like a huge wiki article into the speedreaderbot and
watching it for a few minutes, when you go back and manually
read the article, all the terms are there for you and in context!

Tparser, TDereferencer, And TNamedCollection I was using
in my stockbot but they found me out and i started getting
bogus returns i did however get almost half of all the nasdaq
data since 1980.. (yes all) with my THttpGet and your TParser... now to hit
the next site up with a newer, slower , broader approach.... new ips every two
days , one request every two hours, i should have everything in a year muahahaha
Logged

The watched pot, never boils... But if you walk away from it , the soup burns.  What gives?
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #14 on: January 08, 2008, 10:07:59 AM »

Man I don't have any of that stuff anywhere... I'd love it if you could make me up a care-package and forward it on... I'd love to see that robot GUI one more time, as well as the code for TParser and TInterpreter if you still have them, which had some rocking code in them.

(Side note, of course I'll clean and post here for anyone else interested)
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1] 2
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!