PDA

View Full Version : ## PHP Question ##


Mr Chad
12-31-2005, 12:21 AM
Ok here is what i need, i have a column named "votecount" and i want to make an if statement like this:
if ($votecount = 0) {
}
but it really = NULL is there anyway for me to convert NULL into 0 or somthing...

citricguy
12-31-2005, 12:28 AM
I might not understand what your asking but would this work?

if ($votecount === NULL) {
$votecount = 0;
}

Mr Chad
12-31-2005, 03:02 AM
I might not understand what your asking but would this work?

if ($votecount === NULL) {
$votecount = 0;
}

my bad, im stupid... it was a different error i was having.

but thanks anyway,

davidw
12-31-2005, 10:28 AM
I might not understand what your asking but would this work?

if ($votecount === NULL) {
$votecount = 0;
}Shouldn't it be == rather than ===?

Delphiprogrammi
12-31-2005, 11:10 AM
hi,

carefull here === means something else then ==

=== identical to .....
== equal to

ciao

akanevsky
12-31-2005, 11:24 AM
Just use,

if (!$votecount) {
}

Mr Chad
12-31-2005, 11:17 PM
Just use,

if (!$votecount) {
}

whats that meen?

the !$votecount ?

Chris M
01-01-2006, 01:50 AM
! means not - In this case you could translate !$variable as "$variable is empty or null" :)

=== means exactly equal to and is only used in PHP :)

Chris

Paul M
01-01-2006, 02:02 AM
If you really want to convert it to zero, use $votecount = intval($votecount);