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...

Did you know?Explore Trending and Topic pages for more stories like this.
$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

Trouble with a select list
Hello All!
I was wondering if any of you guys could help me with a small problem I'm having!

need to apply an if/else statement to Tim Thumb script
Not sure how to work this. I essentially want to call a variety of image sizes based on which style

how to query data from website using VC?
I want to query some datum from a website,so I need a program to read data from a .csv file, and ass

single values into sql field
i have a form which i want the user to able to select multiple answers. But i want the answers to be

Working with Global Variables
hi, I'm not really sure why the following code is returning a "Call to a member function getBan

Renaming array keys
The issue: renaming array keys inside a foreach loop.

I'm trying to build a pie chart image w

cURL and Sessions
Ohai.

So, I'm trying to cURL a bunch of things off of a page, and put them into a session. I'

article site help remaining text
Hi all hope you will be fine
I am creating a article site in this site i want to put some text on

Calender Not Opening
The following code is not loading the javascript calender in another window. It's not doing anything

Spaghetti Code
So.

I've pretty much reached the point where I have so many isset s on one page that I can't

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