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

On page view, minus credit
Hello all, please, I need a little help with this script. I am charging one credit (credits can be p

CODE NOT WORKING
Code: [Select]<?php
//include shared codes

include '../lib/common.php';
include

some questions
Hello,

I am looking for the answers for following questions:

1) Does PHP support overl

check comment for html
hi, I just wanted to check if a comment a user posts contains HTML, and if it does, to not allow it

Changing color in GD via variable?
Hey guys, I'm new here. x)

I'm very much a noob when it comes to PHP, but I'm trying to learn

for some reason mysql query not working, not inserting, please check it out
This code is not inserting anything into my db, don't know why, the $_SESSION variable does contain

mod_rewrite.c on windows ??
why it's not working on windows while it's working on other hosts???

this is the code i got

How to replace search button with link?
hi to everbody.
i have a search submit form and button like this :

<form id="f

Word Trimming
Hi Guys & Gals!!

Hope you are all ok....

I need some help with the following

Place specific image in html page when specific name is typed.
Hello,

Fairly new to PHP and was curious if someone might know how to solve a fairly simple r

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