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

Multithreading in Oracle (Java, SQLJ, Pro*C,??) on 10g
I am investigating how to run a Java stored procedure in multithread mode.
I know that if I chang

Different actions for different parts of a string
<?php
function dosomething($string, $else = '') {
if (empty($else))
$string

Share admin accross websites
I'm using .net memberships and roles in one of my sites, but I need to be able to share logins and p

Request for tunning the below query
Hi,

Can any one help me on the below query while improving the performance,

reading xml faster than DB call?
I am trying to optimize a high traffic website, and I enabled a feature where there are three photos

help with this code please?
Hello,

I am trying to build a remote upload script for my image hosting site.

I am usi

Map.php
I am a complete beginner to PHP and am looking for some help with a program I am messing around with

Taxonomy? Classification? Categorisation?
Not sure if there is a way around this classification problem
I have a supplier who produces

Renaming a file that a user uploads to site?
My site allows for registered users to upload images to the site under their own gallery. Currently

Need Help with a query
Hello,
For some reason I am just not getting the right answer when I do this query and not quite

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