Jump to content

Archived

This topic is now archived and is closed to further replies.

mmosel

Can you help me with a header bug?

Recommended Posts

I'm programming a complex site full of many scripts working together. Everything is humming along nicely. I have a side bar section that comes before the main body section (due to my css layout). In my side bar, I have a member box that uses session variables and a little logic to say hello to the user when they are logged in. I also have some cart info that displays when the cart variables are in use.

In another section in my script, I have a large script that publishes an item. Here's the bug. If I display the user's name and the line that shows the cart variables, the item publishes perfectly with no errors. However, if I add another line above the the cart info (which is part of a single variable that gets echoed) I get the ugly headers already sent error.

example:

[code]
if I do it like this:

$cartinfo = "<span class='bluetext' >$t $item, Sub-Total: $$subtotal</span>";

...and then a few lines down in the html:

<?php echo $cartinfo;?>

it works just fine...

----------------------------

but if I do this:

$cartinfo = "<a href=\"?page=cart\">Your Cart:</a><br />
<span class='bluetext' >$t $item, Sub-Total: $$subtotal</span>";

<?php echo $cartinfo;?>

I get the header sent error?

---------------------------

and if I do this:

$cartinfo = "<a href=\"?page=cart\">Your Cart:</a><br />";

and leave out the cart variables, it works fine also...

[/code]

The problem only appears when I have the link and the variable info in the cartinfo variable together!
Anyone have an idea as to why this is the case? Any tips?

Thanks...

Share this post


Link to post
Share on other sites
Just to add on to this bug, I've noticed mixed bugs with IE. Sometimes the script executes without the error, and other times with the error. I'm stumped at the moment.

Share this post


Link to post
Share on other sites
[!--quoteo(post=353107:date=Mar 8 2006, 08:52 PM:name=mmosel)--][div class=\'quotetop\']QUOTE(mmosel @ Mar 8 2006, 08:52 PM) [snapback]353107[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Just to add on to this bug, I've noticed mixed bugs with IE. Sometimes the script executes without the error, and other times with the error. I'm stumped at the moment.
[/quote]


My goodness, that was a strange bug. I don't know why it worked sometimes and not other times.
Anyway, I fixed it. It was pretty simple once I tracked it down. (aren't most bugs that way?)
Basically, I had an include function in the middle of a div tag. I changed the include variable for different needs. The publish script didn't like it because it was trying to call a header function, but the div tag was output already. I moved the include to before the tag for the publish case only.

I still don't know why it worked prior to this for weeks. Strange, but I'm glad it's fixed.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.