Re: Newbie Problem using if statement with &&
- From: "Rik Wasmus" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Mon, 02 Jun 2008 08:41:30 +0200
On Mon, 02 Jun 2008 06:30:51 +0200, John <JohnMay1248@xxxxxxxxx> wrote:
On Jun 1, 8:10 pm, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:John wrote:
> On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:
>> 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...@xxxxxxxxxxxxx
>> ==================- 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
.
- References:
- Newbie Problem using if statement with &&
- From: John
- Re: Newbie Problem using if statement with &&
- From: Jerry Stuckle
- Re: Newbie Problem using if statement with &&
- From: John
- Re: Newbie Problem using if statement with &&
- From: Jerry Stuckle
- Re: Newbie Problem using if statement with &&
- From: John
- Newbie Problem using if statement with &&
- Prev by Date: Re: able to upload 28 meg file, yet php.ini limits posts to 10 megs. What is up with that?
- Next by Date: Re: able to upload 28 meg file, yet php.ini limits posts to 10 megs. What is up with that?
- Previous by thread: Re: Newbie Problem using if statement with &&
- Next by thread: Re: Newbie Problem using if statement with &&
- Index(es):
Relevant Pages
|