2 ifs embedded?

2 ifs embedded?

am 31.07.2009 15:53:08 von tmiller

I need this to say : If row notes is not empty and is alpha echo notes

How do I get the is alpha part in here;

If (!empty($row['notes'])) {


echo(" $trimNotes ");

}

I tried.....

If (IsAlpha($row['notes'])) {


echo(" $trimNotes ");

}

But it broke the whole script.

--Terion


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 15:56:05 von Ashley Sheridan

On Fri, 2009-07-31 at 06:53 -0700, Miller, Terion wrote:
> I need this to say : If row notes is not empty and is alpha echo notes
>
> How do I get the is alpha part in here;
>
> If (!empty($row['notes'])) {
>
>
> echo(" $trimNotes ");
>
> }
>
> I tried.....
>
> If (IsAlpha($row['notes'])) {
>
>
> echo(" $trimNotes ");
>
> }
>
> But it broke the whole script.
>
> --Terion
>
>
I'm not really sure what you are trying to do here? Is it that you want
to have nested queries, or only do something if both conditions have
been met?

Thanks,
Ash
http://www.ashleysheridan.co.uk


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 15:58:19 von Lens Development

Miller, Terion wrote:
> I need this to say : If row notes is not empty and is alpha echo notes
>
> How do I get the is alpha part in here;
>
> If (!empty($row['notes'])) {
>
>
> echo(" $trimNotes ");
>
> }
>
> I tried.....
>
> If (IsAlpha($row['notes'])) {
>
>
> echo(" $trimNotes ");
>
> }
>
> But it broke the whole script.
>
> --Terion
>
>
>
You can write it in one IF statement

If (!empty($row['notes']) && IsAlpha($row['notes'])) {

}


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 16:28:58 von tmiller

On 7/31/09 8:58 AM, "m0s" wrote:

(!empty($row['notes']) && IsAlpha($row['notes']))

I tried that and this one:

If (!empty($row['notes']) && ctype_alpha($row['notes']))

It didn't display the notes at all...

And this one...doesn't display if the field has a 0 in it but I still need =
it to?

If (!empty($row['critical']) && ctype_alnum($row['critical']))

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 16:53:18 von Phpster

On Fri, Jul 31, 2009 at 10:28 AM, Miller,
Terion wrote:
>
>
>
> On 7/31/09 8:58 AM, "m0s" wrote:
>
> (!empty($row['notes']) && IsAlpha($row['notes']))
>
> I tried that and this one:
>
> If (!empty($row['notes']) && ctype_alpha($row['notes']))
>
> It didn't display the notes at all...
>
> And this one...doesn't display if the field has a 0 in it but I still need it to?
>
> If (!empty($row['critical']) && ctype_alnum($row['critical']))
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Hey Teri,
Could the return from the db have a space or something in the value? Perhaps

If (!empty($row['critical']) && ctype_alnum((int)$row['critical']))

might work


--

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 16:59:20 von tmiller

On 7/31/09 9:53 AM, "Bastien Koert" wrote:

On Fri, Jul 31, 2009 at 10:28 AM, Miller,
Terion wrote:
>
>
>
> On 7/31/09 8:58 AM, "m0s" wrote:
>
> (!empty($row['notes']) && IsAlpha($row['notes']))
>
> I tried that and this one:
>
> If (!empty($row['notes']) && ctype_alpha($row['notes']))
>
> It didn't display the notes at all...
>
> And this one...doesn't display if the field has a 0 in it but I still nee=
d it to?
>
> If (!empty($row['critical']) && ctype_alnum($row['critical']))
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Hey Teri,
Could the return from the db have a space or something in the value? Perhap=
s

If (!empty($row['critical']) && ctype_alnum((int)$row['critical']))

might work


--

Bastien

Cat, the other other white meat


It's got me stumped, tried it and it still will not echo if the field has a=
0 in it:

If (!empty($row['critical']) && ctype_alnum((int)$row['critical'])){ =
echo(" Critical violations found: ". $row['critical'] .". ");

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 17:14:10 von Phpster

On Fri, Jul 31, 2009 at 10:59 AM, Miller,
Terion wrote:
>
>
>
> On 7/31/09 9:53 AM, "Bastien Koert" wrote:
>
> On Fri, Jul 31, 2009 at 10:28 AM, Miller,
> Terion wrote:
>>
>>
>>
>> On 7/31/09 8:58 AM, "m0s" wrote:
>>
>> (!empty($row['notes']) && IsAlpha($row['notes']))
>>
>> I tried that and this one:
>>
>> If (!empty($row['notes']) && ctype_alpha($row['notes']))
>>
>> It didn't display the notes at all...
>>
>> And this one...doesn't display if the field has a 0 in it but I still ne=
ed it to?
>>
>> If (!empty($row['critical']) && ctype_alnum($row['critical']))
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Hey Teri,
> Could the return from the db have a space or something in the value? Perh=
aps
>
> If (!empty($row['critical']) && ctype_alnum((int)$row['critical']))
>
> might work
>
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
>
> It's got me stumped, tried it and it still will not echo if the field has=
a 0 in it:
>
> If (!empty($row['critical']) && ctype_alnum((int)$row['critical'])){ =A0 =
=A0 =A0 =A0echo(" Critical violations found: ". $row['critical'] .". ");
>

If you echo it out what is the value?

echo "[".$row['critical']."]";

what do you get?

--=20

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: 2 ifs embedded?

am 31.07.2009 17:16:53 von php-mail

> On 7/31/09 9:53 AM, "Bastien Koert" wrote:
>
> On Fri, Jul 31, 2009 at 10:28 AM, Miller,
> Terion wrote:
> >
> >
> >
> > On 7/31/09 8:58 AM, "m0s" wrote:
> >
> > (!empty($row['notes']) && IsAlpha($row['notes']))
> >
> > I tried that and this one:
> >
> > If (!empty($row['notes']) && ctype_alpha($row['notes']))
> >
> > It didn't display the notes at all...
> >
> > And this one...doesn't display if the field has a 0 in it but I still
> need it to?
> >
> > If (!empty($row['critical']) && ctype_alnum($row['critical']))
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> Hey Teri,
> Could the return from the db have a space or something in the value?
> Perhaps
>
> If (!empty($row['critical']) && ctype_alnum((int)$row['critical']))
>
> might work
>
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
>
> It's got me stumped, tried it and it still will not echo if the field
> has a 0 in it:
>
> If (!empty($row['critical']) && ctype_alnum((int)$row['critical'])){
> echo(" Critical violations found: ". $row['critical'] .". ");
>

empty() regards 0 as an empty value... From the manual:

[quote]
The following things are considered to be empty:

* "" (an empty string)
* 0 (0 as an integer)
* "0" (0 as a string)
* NULL
* FALSE
* array() (an empty array)
* var $var; (a variable declared, but without a value in a class)
[/quote]

HTH

Dan


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 17:40:14 von tmiller

On 7/31/09 10:14 AM, "Bastien Koert" wrote:

On Fri, Jul 31, 2009 at 10:59 AM, Miller,
Terion wrote:
>
>
>
> On 7/31/09 9:53 AM, "Bastien Koert" wrote:
>
> On Fri, Jul 31, 2009 at 10:28 AM, Miller,
> Terion wrote:
>>
>>
>>
>> On 7/31/09 8:58 AM, "m0s" wrote:
>>
>> (!empty($row['notes']) && IsAlpha($row['notes']))
>>
>> I tried that and this one:
>>
>> If (!empty($row['notes']) && ctype_alpha($row['notes']))
>>
>> It didn't display the notes at all...
>>
>> And this one...doesn't display if the field has a 0 in it but I still ne=
ed it to?
>>
>> If (!empty($row['critical']) && ctype_alnum($row['critical']))
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Hey Teri,
> Could the return from the db have a space or something in the value? Perh=
aps
>
> If (!empty($row['critical']) && ctype_alnum((int)$row['critical']))
>
> might work
>
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
>
> It's got me stumped, tried it and it still will not echo if the field has=
a 0 in it:
>
> If (!empty($row['critical']) && ctype_alnum((int)$row['critical'])){ =
echo(" Critical violations found: ". $row['critical'] .". ");
>

If you echo it out what is the value?

echo "[".$row['critical']."]";

what do you get?

--

Bastien

Cat, the other other white meat

If I echo it I get the int that is in the field from the db fine...so it's =
something with my statement?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 17:54:53 von List Manager

Miller, Terion wrote:
>
>
> On 7/31/09 10:14 AM, "Bastien Koert" wrote:
>
> On Fri, Jul 31, 2009 at 10:59 AM, Miller,
> Terion wrote:
>>
>>
>> On 7/31/09 9:53 AM, "Bastien Koert" wrote:
>>
>> On Fri, Jul 31, 2009 at 10:28 AM, Miller,
>> Terion wrote:
>>>
>>>
>>> On 7/31/09 8:58 AM, "m0s" wrote:
>>>
>>> (!empty($row['notes']) && IsAlpha($row['notes']))
>>>
>>> I tried that and this one:
>>>
>>> If (!empty($row['notes']) && ctype_alpha($row['notes']))
>>>
>>> It didn't display the notes at all...
>>>
>>> And this one...doesn't display if the field has a 0 in it but I still need it to?
>>>
>>> If (!empty($row['critical']) && ctype_alnum($row['critical']))
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> Hey Teri,
>> Could the return from the db have a space or something in the value? Perhaps
>>
>> If (!empty($row['critical']) && ctype_alnum((int)$row['critical']))
>>
>> might work
>>
>>
>> --
>>
>> Bastien
>>
>> Cat, the other other white meat
>>
>>
>> It's got me stumped, tried it and it still will not echo if the field has a 0 in it:
>>
>> If (!empty($row['critical']) && ctype_alnum((int)$row['critical'])){ echo(" Critical violations found: ". $row['critical'] .". ");
>>
>
> If you echo it out what is the value?
>
> echo "[".$row['critical']."]";
>
> what do you get?
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
> If I echo it I get the int that is in the field from the db fine...so it's something with my statement?
>

That all depends on WHAT it is you are getting.

Can you tell us WHAT you are getting? Not simply that "I get the int
that is in the field from the db". We don't have any idea what that
value is. Only you know that...


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 18:03:06 von tmiller

On 7/31/09 10:54 AM, "Jim Lucas" wrote:

Miller, Terion wrote:
>
>
> On 7/31/09 10:14 AM, "Bastien Koert" wrote:
>
> On Fri, Jul 31, 2009 at 10:59 AM, Miller,
> Terion wrote:
>>
>>
>> On 7/31/09 9:53 AM, "Bastien Koert" wrote:
>>
>> On Fri, Jul 31, 2009 at 10:28 AM, Miller,
>> Terion wrote:
>>>
>>>
>>> On 7/31/09 8:58 AM, "m0s" wrote:
>>>
>>> (!empty($row['notes']) && IsAlpha($row['notes']))
>>>
>>> I tried that and this one:
>>>
>>> If (!empty($row['notes']) && ctype_alpha($row['notes']))
>>>
>>> It didn't display the notes at all...
>>>
>>> And this one...doesn't display if the field has a 0 in it but I still n=
eed it to?
>>>
>>> If (!empty($row['critical']) && ctype_alnum($row['critical']))
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> Hey Teri,
>> Could the return from the db have a space or something in the value? Per=
haps
>>
>> If (!empty($row['critical']) && ctype_alnum((int)$row['critical']))
>>
>> might work
>>
>>
>> --
>>
>> Bastien
>>
>> Cat, the other other white meat
>>
>>
>> It's got me stumped, tried it and it still will not echo if the field ha=
s a 0 in it:
>>
>> If (!empty($row['critical']) && ctype_alnum((int)$row['critical'])){ =
echo(" Critical violations found: ". $row['critical'] .". ");
>>
>
> If you echo it out what is the value?
>
> echo "[".$row['critical']."]";
>
> what do you get?
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
> If I echo it I get the int that is in the field from the db fine...so it'=
s something with my statement?
>

That all depends on WHAT it is you are getting.

Can you tell us WHAT you are getting? Not simply that "I get the int
that is in the field from the db". We don't have any idea what that
value is. Only you know that...


Numbers are in that field ... So I'm getting 0, 1, 2 etc however many viola=
tions there are

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 18:06:34 von tmiller

On 7/31/09 11:03 AM, "Miller, Terion" wrote:




On 7/31/09 10:54 AM, "Jim Lucas" wrote:

Miller, Terion wrote:
>
>
> On 7/31/09 10:14 AM, "Bastien Koert" wrote:
>
> On Fri, Jul 31, 2009 at 10:59 AM, Miller,
> Terion wrote:
>>
>>
>> On 7/31/09 9:53 AM, "Bastien Koert" wrote:
>>
>> On Fri, Jul 31, 2009 at 10:28 AM, Miller,
>> Terion wrote:
>>>
>>>
>>> On 7/31/09 8:58 AM, "m0s" wrote:
>>>
>>> (!empty($row['notes']) && IsAlpha($row['notes']))
>>>
>>> I tried that and this one:
>>>
>>> If (!empty($row['notes']) && ctype_alpha($row['notes']))
>>>
>>> It didn't display the notes at all...
>>>
>>> And this one...doesn't display if the field has a 0 in it but I still n=
eed it to?
>>>
>>> If (!empty($row['critical']) && ctype_alnum($row['critical']))
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> Hey Teri,
>> Could the return from the db have a space or something in the value? Per=
haps
>>
>> If (!empty($row['critical']) && ctype_alnum((int)$row['critical']))
>>
>> might work
>>
>>
>> --
>>
>> Bastien
>>
>> Cat, the other other white meat
>>
>>
>> It's got me stumped, tried it and it still will not echo if the field ha=
s a 0 in it:
>>
>> If (!empty($row['critical']) && ctype_alnum((int)$row['critical'])){ =
echo(" Critical violations found: ". $row['critical'] .". ");
>>
>
> If you echo it out what is the value?
>
> echo "[".$row['critical']."]";
>
> what do you get?
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
> If I echo it I get the int that is in the field from the db fine...so it'=
s something with my statement?
>

That all depends on WHAT it is you are getting.

Can you tell us WHAT you are getting? Not simply that "I get the int
that is in the field from the db". We don't have any idea what that
value is. Only you know that...


Numbers are in that field ... So I'm getting 0, 1, 2 etc however many viola=
tions there are, so why doesn't this work?

If (ctype_alnum((int)$row['critical'])){ echo(" Critical violations =
found: ". $row['critical'] .". ");

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded? (RESOLVED)

am 31.07.2009 18:11:33 von tmiller

On 7/31/09 10:54 AM, "Jim Lucas" wrote:

Miller, Terion wrote:
>
>
> On 7/31/09 10:14 AM, "Bastien Koert" wrote:
>
> On Fri, Jul 31, 2009 at 10:59 AM, Miller,
> Terion wrote:
>>
>>
>> On 7/31/09 9:53 AM, "Bastien Koert" wrote:
>>
>> On Fri, Jul 31, 2009 at 10:28 AM, Miller,
>> Terion wrote:
>>>
>>>
>>> On 7/31/09 8:58 AM, "m0s" wrote:
>>>
>>> (!empty($row['notes']) && IsAlpha($row['notes']))
>>>
>>> I tried that and this one:
>>>
>>> If (!empty($row['notes']) && ctype_alpha($row['notes']))
>>>
>>> It didn't display the notes at all...
>>>
>>> And this one...doesn't display if the field has a 0 in it but I still n=
eed it to?
>>>
>>> If (!empty($row['critical']) && ctype_alnum($row['critical']))
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> Hey Teri,
>> Could the return from the db have a space or something in the value? Per=
haps
>>
>> If (!empty($row['critical']) && ctype_alnum((int)$row['critical']))
>>
>> might work
>>
>>
>> --
>>
>> Bastien
>>
>> Cat, the other other white meat
>>
>>
>> It's got me stumped, tried it and it still will not echo if the field ha=
s a 0 in it:
>>
>> If (!empty($row['critical']) && ctype_alnum((int)$row['critical'])){ =
echo(" Critical violations found: ". $row['critical'] .". ");
>>
>
> If you echo it out what is the value?
>
> echo "[".$row['critical']."]";
>
> what do you get?
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
> If I echo it I get the int that is in the field from the db fine...so it'=
s something with my statement?
>

That all depends on WHAT it is you are getting.

Can you tell us WHAT you are getting? Not simply that "I get the int
that is in the field from the db". We don't have any idea what that
value is. Only you know that...


Got it..yay...

If (ctype_digit($row['critical'])){ echo(" Critical violations found=
: ". $row['critical'] .". ");

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded?

am 31.07.2009 18:13:15 von List Manager

Miller, Terion wrote:
>
>
> On 7/31/09 11:03 AM, "Miller, Terion" wrote:
>
>
>
>
> On 7/31/09 10:54 AM, "Jim Lucas" wrote:
>
> Miller, Terion wrote:
>>
>> On 7/31/09 10:14 AM, "Bastien Koert" wrote:
>>
>> On Fri, Jul 31, 2009 at 10:59 AM, Miller,
>> Terion wrote:
>>>
>>> On 7/31/09 9:53 AM, "Bastien Koert" wrote:
>>>
>>> On Fri, Jul 31, 2009 at 10:28 AM, Miller,
>>> Terion wrote:
>>>>
>>>> On 7/31/09 8:58 AM, "m0s" wrote:
>>>>
>>>> (!empty($row['notes']) && IsAlpha($row['notes']))
>>>>
>>>> I tried that and this one:
>>>>
>>>> If (!empty($row['notes']) && ctype_alpha($row['notes']))
>>>>
>>>> It didn't display the notes at all...
>>>>
>>>> And this one...doesn't display if the field has a 0 in it but I still need it to?
>>>>
>>>> If (!empty($row['critical']) && ctype_alnum($row['critical']))
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>> Hey Teri,
>>> Could the return from the db have a space or something in the value? Perhaps
>>>
>>> If (!empty($row['critical']) && ctype_alnum((int)$row['critical']))
>>>
>>> might work
>>>
>>>
>>> --
>>>
>>> Bastien
>>>
>>> Cat, the other other white meat
>>>
>>>
>>> It's got me stumped, tried it and it still will not echo if the field has a 0 in it:
>>>
>>> If (!empty($row['critical']) && ctype_alnum((int)$row['critical'])){ echo(" Critical violations found: ". $row['critical'] .". ");
>>>
>> If you echo it out what is the value?
>>
>> echo "[".$row['critical']."]";
>>
>> what do you get?
>>
>> --
>>
>> Bastien
>>
>> Cat, the other other white meat
>>
>> If I echo it I get the int that is in the field from the db fine...so it's something with my statement?
>>
>
> That all depends on WHAT it is you are getting.
>
> Can you tell us WHAT you are getting? Not simply that "I get the int
> that is in the field from the db". We don't have any idea what that
> value is. Only you know that...
>
>
> Numbers are in that field ... So I'm getting 0, 1, 2 etc however many violations there are, so why doesn't this work?
>
> If (ctype_alnum((int)$row['critical'])){ echo(" Critical violations found: ". $row['critical'] .". ");
>

So, the only thing you will see is a number? Correct? What is the
range that the number will fall between?

And, does zero mean anything different then 1, 2, 3...

If, all you want to do is make sure that $row['critical'] is a number
and the value is within a range of numbers, so this.

if (
isset($row['critical']) &&
is_numeric($row['critical']) &&
in_array($row['critical'], range(0, 200))
} {
...
}


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: 2 ifs embedded? (RESOLVED)

am 01.08.2009 20:57:27 von Colin Guthrie

'Twas brillig, and Miller, Terion at 31/07/09 17:11 did gyre and gimble:
> If (ctype_digit($row['critical'])){ echo(" Critical violations found: ". $row['critical'] .". ");

Remember that empty() does clever stuff for you.

empty('') == true
empty(0) == true
empty('0') == true
empty(1) == false
empty(2) == false
empty('foo') == false

I suspect you were just being bitten by a misconception of what empty()
was supposed to do when you passed certain values to it.

isset() and empty() are subtly different.

Col




--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php