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

Best way to check for end of a record and send it back to the first record
I'm hoping someone can help me out and explain the best way to accomplish this.

What I'm doin

Optimize Code
Just started getting into the use of cookies. The following code will redirect users to a set URL s

Showing selected item at top of list
Hi,

I've got a list of names which i am fetching from database like this:
$qry = db_query

please help me... my password gets encrypted but not able to get in database
hai guys,
please help me... in the following function my password gets encrypted but no

Need help Updating SQL Server Express DB from c# :(
Please can anyone help with:-
1 How to sructure the strSelect statement.
2 How to instruct

Using CSS to format MySQL query
Hi,

If i want to have a news page on my site, which displays all records of a table in descen

add text and number image
hi guys ..

ok see i want the user to add their name and pick a number then click get it and i

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_
Can anyone view my code and tell me why im getting the error:
Parse error: syntax error, unexpect

Help with Password Encoding/Decoding?
Trying to design a "change password" tool. On my signup code I'm using base64_encode, now

problems with php variables in mysql query
i can't seem to get the following query to work.

select $q1c from $vote_rate where id = $re

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