|
Posted by J.O. Aho on 09/28/06 11:42
Michael Trausch wrote:
> J.O. Aho wrote:
>> Would guess you don't access the value in the right way
>> Tried
>>
>> echo $array_name['takesPlace'];
>>
>> or
>>
>> echo $array_name[1];
>>
>>
>> If you are using $array_name[takesPlace], you can get a random result.
>>
>>
>>
>> //Aho
>
> The 0 value comes from:
>
> $snooze_until = $row['snooze_until'];
>
> if($snooze_until > time())
> {
> // do something (which doesn't work)
> }
>
> // Debugging output
>
> echo "$snooze_until is snooze till time.\n";
> print_r($row);
>
> Is there something subtly incorrect in there that I'm missing?
>
> Echoing the row's column directly yields the correct result, *as a
> string*. However, I'm doing a numeric comparison on it, which appears
> to be failing somehow or another; it appears that PHP is changing the
> value to 0 when it performs its implicit conversion. So, what I'm
> wondering again -- is this a quirk with a workaround, am I doing
> something subtly or blatantly wrong, or is this a bug?
PHP shouldn't be that picky about types, but if you store the value in the
database as a varchar and not int, then there could be a type error, try with
if(intval($snooze_until) > time()) {
//do something
}
//Aho
[Back to original message]
|