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

Date Format
Hi there,

I have a date format like this right now:
Sat, 17 Oct 2009 17:04:00

I ne

Can't shake the "Warning: include()" error
I've just uploaded my site to a new server and where I have PHP include tags in my HTML, the browser

Estimations and Effort
HI Gurus,

Would like to know whether SAP have a provision for carrying out the Project es

Sort a two dimensional array.
Hi. I've set up a two dimensional array that reads as follows:

Code: $modifiedData = array(

New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understan

Inserting the current date/time while submitting the forum
What do I need to add below to update the current date/time? I have a field in the database called d

Need help: how to catch acess of undefined class properties
Hello. I am learning OO with PHP and have hit a problem.
Some code runs as perfectly valid code,

Format String help
I have a textbox where a person enters an application number. the application number is 10 characte

jquery validation in codeIgniter
hai i need to add client side validation to my fiels which are selected in a forloop.the fields are

natcasesort works on one server but not on another
Hi

I have a problem that I was hoping that someone can help me with.

I'm trying to use

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