Page 2 of 2

Posted: Thu May 20, 2004 7:51 pm
by greree
The space before the <? isn't in my code. And besides, when I take line 18 out it works perfectly.

Line 18 is the line I need to insert to credit affiliates:

Code: Select all

echo "<img src="http://www.yoursite.com/cgi-bin/affiliates/sale.cgi?payment=$fOrder&#1111;amount]" border="0">";
It's not part of the original code.

Posted: Thu May 20, 2004 8:11 pm
by Unipus
Well then you know that there's a call to a header function of some sort (including sessions) happening AFTER line 18.

Posted: Thu May 20, 2004 8:25 pm
by greree
The error message says line 67:

Code: Select all

setcookie("current_page", $page);

Posted: Thu May 20, 2004 8:32 pm
by Unipus
From the manual:

If output exists prior to calling this function, setcookie() will fail and return FALSE. If setcookie() successfully runs, it will return TRUE. This does not indicate whether the user accepted the cookie.

Posted: Thu May 20, 2004 9:15 pm
by launchcode
greree - exactly - on line 18 you echo something out, which is sending a whole load of headers to the browser and online 67 you're trying to set a cookie - which needs to change the headers, but it cannot because they've already been sent.

You cannot have it in this order, there is no other way to explain it.

Posted: Thu May 20, 2004 9:38 pm
by greree
Ok, is there any way to trigger the cgi file without echoing it?

Posted: Thu May 20, 2004 9:41 pm
by launchcode
Echo it somewhere else? (i.e. after all of your cookie/header stuff is over)

Posted: Thu May 20, 2004 10:08 pm
by greree
I tried that, but I couldn't find any other place it would work even partially. It needs to trigger only if PayPal returns a successful purchase, and it needs to pick up the amount of the purchase, which is variable. I guess I'll just have to experiment. In the mean time I put a @ in front of the setcookie line so the error message would go away.

Posted: Fri May 21, 2004 4:11 pm
by Unipus
Try this idea: instead of echoing the output for the paypal image, just set a flag at that time indicating that it's set. Then, later, AFTER all your cookie and header work is done, you can perform the echo:

if ($paypalset) {
echo "<img ... >";
}


You get the idea?

Posted: Sat May 22, 2004 1:21 am
by greree
I get the idea, but I don't have a clue how to do it. I'll see if I can figure it out. Thanks for the info.