Re: I know this is not easy and I'm not stupid but...
| From: | Jim Lucas | Date: | Thu, 09 Aug 2007 18:07:57 +0000 |
| Subject: | Re: I know this is not easy and I'm not stupid but... | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260523@lists.php.net to get a copy of this message | ||
Stut wrote:
Please include the list when replying. Phil Curry wrote:PHP does not have a type of tinyint knowing now that this comes from a database, if it is mysql, then it is of type string PHP converts all fields when pulled from the database into strings. It does not take into account what type the field is actually set to in mysql. Try puting a (int) in front of the condition like this if ( (int)$userValues['afterDark'] == 0 ) { ... } Maybe this will helpPhil Curry wrote:Don't have to do a dump, I know its a tinyint(1), not null, default 0how can this be? This is not the first time I've run into a situation like this. What am I missing?Add a line at 102.5... var_dump($userValues['afterDark']); What type is that variable?line 102 echo ($userValues['afterDark']); // outputs 1 line 103 if ( $userValues['afterDark'] == 0 ) { // passes
That would be the type in the database, not the type of that variable at that time. -Stut-- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare