Page 1 of 1

OMFG.

Posted: Tue Sep 16, 2003 2:26 am
by m3mn0n
This really got on my nerves. I had a very simply email job to do and I couldn't figure out what was wrong. :roll:

For developing PHP for more than a year now, I was disapointed in myself...heh. Here is a mock up of the structure of the script:

Code: Select all

<?php
// check if submit was sent via request method, if not shout error msg

// check to see if email address is valid, if not send to error pg via header()

// check to see if variables are set, if not send to error pg via header()

// set variables for mail and trim incoming variables

// send email, if it was sent, it forwards a user to a thank you page via header(), if not sends to error pg via header()
?>
Now I was playing with this script forever, revision after revision, and the email checker and variable checker portions of the script were not functional AT ALL.

After about the 10th rewrite of the entire script, I tested something out; instead of forwarding to a thank you page, i would add phpinfo() to see what the settings of the server were.

I added jibberish to the fields thinking it wouldn't matter, and then submit the form. Low and behold; It starts to work. I was puzzled. I didn't even bother to anylize the phpinfo() page, i just re-added the header() function that sends to a thank you page; and tried again.

ERROR! I didn't work. This freaked me out. I went ahead and re-added phpinfo() and tested again. It worked!

Angry, frustrated, and happy all at once i went ahead and added require("thankyoupage.html") instead of the header() forwarding it there. And it works like a charm now.




Now my question is; why did it ignore an entire portion of my script because of that header() function? I've never heard of a problem like this before so I hope some of you veterans can clear this up for me.



btw: the original script worked perfectly on my testing server which runs php 4.1.1. Site that this all happened on has 4.2.3. This script has no HTML on it, it's pure PHP.

Posted: Wed Sep 17, 2003 6:42 pm
by m3mn0n
wow...nobody has seen anything like this before? :(

hmmm

Posted: Fri Sep 19, 2003 6:03 pm
by evilMind
well, w/o seeing any code it's not suprising that nobody has responded. It's hard to shoot a deer in the dark. However, I'll be the lucky .. person .. to *attempt* at answering your question.

1) did you have a exit(); or die(); call after the header() call?
2) is the header() call a valid call or is it bailing out because it's not valid?
3) are the headers for the page already sent? try using
if ( !headers_sent() ) {
header('Location: somepage.html');
exit();
} else {
echo "AHH! It's because the headers are already sent!!!";
}
4) if the headers keep getting sent for some reason try turning on output buffering. ob_start(); ...code... ob_flush();

Re: hmmm

Posted: Fri Sep 19, 2003 6:35 pm
by m3mn0n
evilMind wrote:well, w/o seeing any code it's not suprising that nobody has responded.
I shouldn't need to post the code. The comments describe what is happening and it's pretty easy to paint a mental picture of what is going on in the script.

There is no HTML headers on that page, like I said. Also no headers are being parsed on the page unless there is an error within the code as the comments describe.

I figured this is one of thoses rare little things about the syntax that I didn't know, or something having to do with my php version or a setting...

Thanks for the lovely responce. :roll:

Posted: Sat Sep 20, 2003 5:58 am
by igoy
curious... how curious.... hmmmmmmmmmmm

Re: hmmm

Posted: Sat Sep 20, 2003 9:19 am
by jason
Sami wrote:
evilMind wrote:well, w/o seeing any code it's not suprising that nobody has responded.
I shouldn't need to post the code. The comments describe what is happening and it's pretty easy to paint a mental picture of what is going on in the script.
It's been my experience that comments and code are two completely different things. By showing us the comments, you show us what you intended the program to do. The code shows us what you told the program to do. Two completely, completely, 100% completly different things.

My guess, from what I have seen, is that there is an error in the logic in your code. But to give you an accurate answer, I would need to see the code.

:D

Posted: Sat Sep 20, 2003 12:24 pm
by unixchick
omfg, post the code... :wink:
lol, serriously

Coders minds are like parsers, they ignore the "//" comments

Posted: Sun Sep 21, 2003 9:50 am
by igoy
I can agree with Jason and UnixChick.... ahem apart from one having cool pic as avatar and other says about "CHICK".. ;)..

seriously.. if that's not a code you have written for CIA or FBI, that should be kept confidential..lol... you should show it to us... maybe then only you can get some logical answer... and then maybe you will say ..., " OMFG, there was that thing... now I know !!!"

Posted: Sun Sep 21, 2003 10:06 am
by Nay
igoy, maybe it's like......

If I tell you, then I would have to kill you. *puts on sun glasses* :D.

LOL

*ahem*. Okay, sorry, I'm getting a little off topic.

-Nay