470,819 Members | 1,602 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,819 developers. It's quick & easy.

Newbie Problem using if statement with &&

Hello all.

I am a PHP newbie and am having an issue using the && in an if
statement. here is the code:

if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}

Ok when the code runs it and both conditions are true nothing happens.

Testing:

$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.

$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true

If i put these if statements on the page they both work fine.

if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

Thanks in advance for any help
Jun 2 '08 #1
9 1337
John wrote:
Hello all.

I am a PHP newbie and am having an issue using the && in an if
statement. here is the code:

if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}

Ok when the code runs it and both conditions are true nothing happens.

Testing:

$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.

$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true

If i put these if statements on the page they both work fine.

if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

Thanks in advance for any help
When things like this fail, a good first step is to echo the values
involved.

For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird"]
and $rowWork["wEarlyBird"]? Are you getting what you think you should
be getting from date("Y-m-d")? Also - is $_REQUEST["frmIsEarlyBird"]
equal to "1" or 1? They are two different values.

Also, $_REQUEST is generally not a good thing to use, If it's coming
from a POSTed forum, use $_POST. If it's in the URL, use $_GET.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 2 '08 #2
Yeah I have tested the vslues and they are valid. As i said in the
original post:
Testing:

$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.

$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true

If i put these if statements on the page they both work fine.
(validate as true)

if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

On Jun 1, 4:42*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
John wrote:
Hello all.
I am a PHP newbie and am having an issue using the && in an if
statement. here is the code:
if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}
Ok when the code runs it and both conditions are true nothing happens.
Testing:
$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.
$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true
If i put these if statements on the page they both work fine.
* * *if ($_REQUEST["frmIsEarlyBird"] == "1") {
* * * * * echo "<br><br>TRUE<br><br>";
* * *} else {
* * * * * echo "<br><br>False<br><br>";
* * *}
* * *if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
* * * * * echo "<br><br>TRUE<br><br>";
* * *} else {
* * * * * echo "<br><br>False<br><br>";
* * *}
Thanks in advance for any help

When things like this fail, a good first step is to echo the values
involved.

For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird"]
and $rowWork["wEarlyBird"]? *Are you getting what you think you should
be getting from date("Y-m-d")? *Also - is $_REQUEST["frmIsEarlyBird"]
equal to "1" or 1? *They are two different values.

Also, $_REQUEST is generally not a good thing to use, *If it's coming
from a POSTed forum, use $_POST. *If it's in the URL, use $_GET.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
Jun 2 '08 #3
John wrote:
On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>John wrote:
>>Hello all.
I am a PHP newbie and am having an issue using the && in an if
statement. here is the code:
if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}
Ok when the code runs it and both conditions are true nothing happens.
Testing:
$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.
$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true
If i put these if statements on the page they both work fine.
if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}
if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}
Thanks in advance for any help
When things like this fail, a good first step is to echo the values
involved.

For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird"]
and $rowWork["wEarlyBird"]? Are you getting what you think you should
be getting from date("Y-m-d")? Also - is $_REQUEST["frmIsEarlyBird"]
equal to "1" or 1? They are two different values.

Also, $_REQUEST is generally not a good thing to use, If it's coming
from a POSTed forum, use $_POST. If it's in the URL, use $_GET.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Yeah I have tested the vslues and they are valid. As i said in the
original post:
Testing:

$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.

$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true

If i put these if statements on the page they both work fine.
(validate as true)

if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}
(Top posting fixed)

Well, obviously something is not as you describe, because '&&' has a
lower priority than either '==' or '<', which is why I asked you to
verify this. It's either the data or the statement you supplied doesn't
match what you have in your code. I'm just trying to eliminate
possibilities.

P.S. Please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 2 '08 #4
John wrote:
On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>John wrote:
>>Hello all.
I am a PHP newbie and am having an issue using the && in an if
statement. here is the code:
if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}
Ok when the code runs it and both conditions are true nothing happens.
Testing:
$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.
$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true
If i put these if statements on the page they both work fine.
if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}
if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}
Thanks in advance for any help
When things like this fail, a good first step is to echo the values
involved.

For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird"]
and $rowWork["wEarlyBird"]? Are you getting what you think you should
be getting from date("Y-m-d")? Also - is $_REQUEST["frmIsEarlyBird"]
equal to "1" or 1? They are two different values.

Also, $_REQUEST is generally not a good thing to use, If it's coming
from a POSTed forum, use $_POST. If it's in the URL, use $_GET.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -

Yeah I have tested the vslues and they are valid. As i said in the
original post:
Testing:

$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.

$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true

If i put these if statements on the page they both work fine.
(validate as true)

if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}
(Top posting fixed)

Well, obviously something is not as you describe, because '&&' has a
lower priority than either '==' or '<', which is why I asked you to
verify this. It's either the data or the statement you supplied doesn't
match what you have in your code. I'm just trying to eliminate
possibilities.

P.S. Please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '08 #5
On Jun 1, 8:10*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
John wrote:
On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
John wrote:
Hello all.
I am a PHP newbie and am having an issue using the && in an if
statement. here is the code:
if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}
Ok when the code runs it and both conditions are true nothing happens.
Testing:
$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.
$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true
If i put these if statements on the page they both work fine.
* * *if ($_REQUEST["frmIsEarlyBird"] == "1") {
* * * * * echo "<br><br>TRUE<br><br>";
* * *} else {
* * * * * echo "<br><br>False<br><br>";
* * *}
* * *if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
* * * * * echo "<br><br>TRUE<br><br>";
* * *} else {
* * * * * echo "<br><br>False<br><br>";
* * *}
Thanks in advance for any help
When things like this fail, a good first step is to echo the values
involved.
For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird"]
and $rowWork["wEarlyBird"]? *Are you getting what you think you should
be getting from date("Y-m-d")? *Also - is $_REQUEST["frmIsEarlyBird"]
equal to "1" or 1? *They are two different values.
Also, $_REQUEST is generally not a good thing to use, *If it's coming
from a POSTed forum, use $_POST. *If it's in the URL, use $_GET.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -

*Yeah I have tested the vslues and they are valid. As i said in the
*original post:
*>
*>
*Testing:
*>
*$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
*string of 1 or 0 depending on what im sending.
*>
*$rowWork["wEarlyBird"] Has a valid date in it and should validate as
*true
*>
*If i put these if statements on the page they both work fine.
*(validate as true)
*>
** * *if ($_REQUEST["frmIsEarlyBird"] == "1") {
** * * * * echo "<br><br>TRUE<br><br>";
** * *} else {
** * * * * echo "<br><br>False<br><br>";
** * *}
*>
** * *if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
** * * * * echo "<br><br>TRUE<br><br>";
** * *} else {
** * * * * echo "<br><br>False<br><br>";
** * *}
*>

(Top posting fixed)

Well, obviously something is not as you describe, because '&&' has a
lower priority than either '==' or '<', which is why I asked you to
verify this. *It's either the data or the statement you supplied doesn't
match what you have in your code. *I'm just trying to eliminate
possibilities.

P.S. Please don't top post. *Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -

- Show quoted text -
Sorry bout top posting im new to this group thing as well as php.
Thanks for trying to help me. the code below is an exact paste from
the page. I have the first two if statements there to test the
variables. When the code runs I see TRUE TRUE and thats it the die
never runs. It is my understanding that I am trying to say in my
statement that if $_REQUEST["frmIsEarlyBird"] == "1" is true AND
date("Y-m-d") < $rowWork["wEarlyBird"] is true run the die. I dont
understand why the first two if statetments would each display true
but the third not run.

if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}
Jun 27 '08 #6
On Mon, 02 Jun 2008 06:30:51 +0200, John <Jo*********@gmail.comwrote:
On Jun 1, 8:10*pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>John wrote:
On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
John wrote:
Hello all.
I am a PHP newbie and am having an issue using the && in an if
statement. here is the code:
if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}
Ok when the code runs it and both conditions are true nothing
happens.
>>Testing:
$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.
$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true
If i put these if statements on the page they both work fine.
* * *if ($_REQUEST["frmIsEarlyBird"] == "1") {
* * * * * echo "<br><br>TRUE<br><br>";
* * *} else {
* * * * * echo "<br><br>False<br><br>";
* * *}
* * *if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
* * * * * echo "<br><br>TRUE<br><br>";
* * *} else {
* * * * * echo "<br><br>False<br><br>";
* * *}
Thanks in advance for any help
When things like this fail, a good first step is to echo the values
involved.
>For instance, right now, what do you have in
$_REQUEST["frmIsEarlyBird"]
>and $rowWork["wEarlyBird"]? *Are you getting what you think you
should
>be getting from date("Y-m-d")? *Also - is $_REQUEST["frmIsEarlyBird"]
equal to "1" or 1? *They are two different values.
>Also, $_REQUEST is generally not a good thing to use, *If it's coming
from a POSTed forum, use $_POST. *If it's in the URL, use $_GET.
>--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
>- Show quoted text -

*Yeah I have tested the vslues and they are valid. As i said in the
*original post:
*>
*>
*Testing:
*>
*$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
*string of 1 or 0 depending on what im sending.
*>
*$rowWork["wEarlyBird"] Has a valid date in it and should validate as
*true
*>
*If i put these if statements on the page they both work fine.
*(validate as true)
*>
** * *if ($_REQUEST["frmIsEarlyBird"] == "1") {
** * * * * echo "<br><br>TRUE<br><br>";
** * *} else {
** * * * * echo "<br><br>False<br><br>";
** * *}
*>
** * *if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
** * * * * echo "<br><br>TRUE<br><br>";
** * *} else {
** * * * * echo "<br><br>False<br><br>";
** * *}
*>

(Top posting fixed)

Well, obviously something is not as you describe, because '&&' has a
lower priority than either '==' or '<', which is why I asked you to
verify this. *It's either the data or the statement you supplied doesn't
match what you have in your code. *I'm just trying to eliminate
possibilities.

Sorry bout top posting im new to this group thing as well as php.
Thanks for trying to help me. the code below is an exact paste from
the page. I have the first two if statements there to test the
variables. When the code runs I see TRUE TRUE and thats it the die
never runs. It is my understanding that I am trying to say in my
statement that if $_REQUEST["frmIsEarlyBird"] == "1" is true AND
date("Y-m-d") < $rowWork["wEarlyBird"] is true run the die. I dont
understand why the first two if statetments would each display true
but the third not run.

if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}
If that's the actual code, with nothing in between that can alter either
of the variables, I'm thoroughly puzzled. 100% sure you're not misspelling
one of the variable names? And have you enabled display_errors and set
error_reporting to E_ALL | E_STRICT ?
--
Rik Wasmus
....spamrun finished
Jun 27 '08 #7
John <Jo*********@gmail.comwrote:
: I dont
: understand why the first two if statetments would each display true
: but the third not run.

: if ($_REQUEST["frmIsEarlyBird"] == "1") {
: echo "<br><br>TRUE<br><br>";
: } else {
: echo "<br><br>False<br><br>";
: }

: if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
: echo "<br><br>TRUE<br><br>";
: } else {
: echo "<br><br>False<br><br>";
: }

: if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
: $rowWork["wEarlyBird"]) {
: die("<h1>The earlybird special has ended.</h1>");
: }
What happens if you replace your last statement with this one?

if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
echo 'hereiam<br/>';
}
--thelma
[with no real idea of what's going on]
Jun 27 '08 #8
On 2 Jun, 04:30, John <JohnMay1...@gmail.comwrote:
On Jun 1, 8:10 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
John wrote:
On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>John wrote:
>>Hello all.
>>I am a PHP newbie and am having an issue using the && in an if
>>statement. here is the code:
>>if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
>>$rowWork["wEarlyBird"]) {
>>die("<h1>The earlybird special has ended.</h1>");
>>}
>>Ok when the code runs it and both conditions are true nothing happens.
>>Testing:
>>$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
>>string of 1 or 0 depending on what im sending.
>>$rowWork["wEarlyBird"] Has a valid date in it and should validate as
>>true
>>If i put these if statements on the page they both work fine.
>> if ($_REQUEST["frmIsEarlyBird"] == "1") {
>> echo "<br><br>TRUE<br><br>";
>> } else {
>> echo "<br><br>False<br><br>";
>> }
>> if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
>> echo "<br><br>TRUE<br><br>";
>> } else {
>> echo "<br><br>False<br><br>";
>> }
>>Thanks in advance for any help
>When things like this fail, a good first step is to echo the values
>involved.
>For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird"]
>and $rowWork["wEarlyBird"]? Are you getting what you think you should
>be getting from date("Y-m-d")? Also - is $_REQUEST["frmIsEarlyBird"]
>equal to "1" or 1? They are two different values.
>Also, $_REQUEST is generally not a good thing to use, If it's coming
>from a POSTed forum, use $_POST. If it's in the URL, use $_GET.
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
>jstuck...@attglobal.net
>==================- Hide quoted text -
>- Show quoted text -
Yeah I have tested the vslues and they are valid. As i said in the
original post:
>
>
Testing:
>
$_REQUEST["frmIsEarlyBird"] is a valid form request and returns a
string of 1 or 0 depending on what im sending.
>
$rowWork["wEarlyBird"] Has a valid date in it and should validate as
true
>
If i put these if statements on the page they both work fine.
(validate as true)
>
if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}
>
if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}
>
(Top posting fixed)
Well, obviously something is not as you describe, because '&&' has a
lower priority than either '==' or '<', which is why I asked you to
verify this. It's either the data or the statement you supplied doesn't
match what you have in your code. I'm just trying to eliminate
possibilities.
P.S. Please don't top post. Thanks.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
- Show quoted text -

Sorry bout top posting im new to this group thing as well as php.
Thanks for trying to help me. the code below is an exact paste from
the page. I have the first two if statements there to test the
variables. When the code runs I see TRUE TRUE and thats it the die
never runs. It is my understanding that I am trying to say in my
statement that if $_REQUEST["frmIsEarlyBird"] == "1" is true AND
date("Y-m-d") < $rowWork["wEarlyBird"] is true run the die. I dont
understand why the first two if statetments would each display true
but the third not run.

if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}
First a hint. Only use double quotes, if you want to perform variable
substitution within a string. Otherwise, try to use single quotes.

Now, when I get a problem like this, I tend to echo out all the values
and all the intermediate results. So please replace your code with
this and then post the output here:

echo 'frmIsEarlyBird='.$_REQUEST['frmIsEarlyBird].'=<br />';
echo 'date='.date('Y-m-d').'=<br />';
echo 'wEarlyBird='.$rowWork['wEarlyBird'].'=<br />';
echo '($_REQUEST["frmIsEarlyBird"] == \'1\')='.
($_REQUEST['frmIsEarlyBird'] == '1').'=<br />';
echo '(date(\'Y-m-d\') < $rowWork[\'wEarlyBird\'])='.(date(\'Y-m-d\')
< $rowWork[\'wEarlyBird\']).'=';
echo '&&='.($_REQUEST['frmIsEarlyBird'] == '1' && date(\'Y-m-d\') <
$rowWork[\'wEarlyBird\']).'=';
if ($_REQUEST['frmIsEarlyBird'] == '1' && date('Y-m-d') <
$rowWork['wEarlyBird']) {
die('<h1>The earlybird special has ended.</h1>');

}
Jun 27 '08 #9
On Sun, 1 Jun 2008 21:30:51 -0700 (PDT), John wrote:
Sorry bout top posting im new to this group thing as well as php.
Thanks for trying to help me. the code below is an exact paste from
the page. I have the first two if statements there to test the
variables. When the code runs I see TRUE TRUE and thats it the die
never runs. It is my understanding that I am trying to say in my
statement that if $_REQUEST["frmIsEarlyBird"] == "1" is true AND
date("Y-m-d") < $rowWork["wEarlyBird"] is true run the die. I dont
understand why the first two if statetments would each display true
but the third not run.

if ($_REQUEST["frmIsEarlyBird"] == "1") {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if (date("Y-m-d") < $rowWork["wEarlyBird"]) {
echo "<br><br>TRUE<br><br>";
} else {
echo "<br><br>False<br><br>";
}

if ($_REQUEST["frmIsEarlyBird"] == "1" && date("Y-m-d") <
$rowWork["wEarlyBird"]) {
die("<h1>The earlybird special has ended.</h1>");
}
Are you 100% sure that this is a problem with the && operator and not a
problem with the fact that your < maybe should be a ? 'Cause that
LOOKS like it's testing that the current time is BEFORE the "wEarlyBird"
thing, not after it.

--
Any research done on how to efficiently use computers has been long lost
in the mad rush to upgrade systems to do things that aren't needed by
people who don't understand what they are really supposed to do with them.
-- Graham Reed
Jun 27 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Bryan | last post: by
1 post views Thread by chis2k | last post: by
30 posts views Thread by James Daughtry | last post: by
3 posts views Thread by Fred Chateau | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.