Trying to run a cgi script from a php script.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

greree
Forum Newbie
Posts: 15
Joined: Sun Dec 14, 2003 10:34 am

Post 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.
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

Well then you know that there's a call to a header function of some sort (including sessions) happening AFTER line 18.
greree
Forum Newbie
Posts: 15
Joined: Sun Dec 14, 2003 10:34 am

Post by greree »

The error message says line 67:

Code: Select all

setcookie("current_page", $page);
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post 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.
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post 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.
greree
Forum Newbie
Posts: 15
Joined: Sun Dec 14, 2003 10:34 am

Post by greree »

Ok, is there any way to trigger the cgi file without echoing it?
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Echo it somewhere else? (i.e. after all of your cookie/header stuff is over)
greree
Forum Newbie
Posts: 15
Joined: Sun Dec 14, 2003 10:34 am

Post 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.
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post 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?
greree
Forum Newbie
Posts: 15
Joined: Sun Dec 14, 2003 10:34 am

Post 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.
Post Reply