Checking if variable is 0 as opposed to NULL/Empty...


Posted on 16th Feb 2014 07:03 pm by admin

I'm trying to write some code that will retrieve a user's access level from my database and if it doesn't return any values then I want to set the access variable to 2.

I'm using...

$access_id = $useraccess["0"]["access_id"];

if (!$access_id) {$access_id = '2';}

Where $useraccess is the array I've got from the database. I set the variable $access_id to whatever the user's access_id field contains. Then I check the variable because if the access_id field is empty then I know the user hasn't had one specified and should be given the site default. The problem is one of the access levels is '0' which is returning an empty value and then setting it to two.

Has anyone any idea how to stop this please?

No comments posted yet

Your Answer:

Login to answer
50 Like 39 Dislike
Previous forums Next forums
Other forums

md5 is it unique
I know this is most likely one of many simple questions that can be found semi easily. But I'm press

LSB (PHP 5.3) problem with static value!
hello,

i'm having a problem. static::$text variable gets lost at some point. can someone plea

Output Full URL of Current Page
Let's say I am currently viewing a dynamic page:

http://www.mydomain.com/directory/index.php

Is there a way to override built in php functions without APD?
I am trying to use the
rename_function()
override_function()
options that are built into

Parse Error with doctype
I'm getting a parse error with this simple code. I don't get it. It worked one time then when I relo

Calling strings from other php class
I have test1.php{
$string1;
$string2;
....
... //10 strings in this class <

Need help PLEASE
ok i have this warning showing up

Warning: in_array() [function.in-array]: Wrong datatype for

How to get variable value on next page
Hello friends
i am working on payentry page ..there i have this code.........

Ajax Error since Upgrading to 3.5
Ever since upgrading my site to .NET 3.5 (I needed LINQ), I've been getting this annoying error on o

Procedural to OOP
John Kleijn said that to avoid writing "crappy code", we should learn OOP and common OO pr

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash