Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3351762
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:56:52+00:00 2026-05-18T01:56:52+00:00

Hey guys, Im doing a series of if statements based on a session variable

  • 0

Hey guys, Im doing a series of if statements based on a session variable that is set (which looks at a value in the DB and then decides whether to empty the session, or name it. However I’m having problems in that the session is always named, regardless of whether the record in the database is ‘0’ or not. The query works fine when run in mysql. Here’s the code:

session_start();

$_SESSION['MemberType'] = '';

mysql_select_db($database_choices, $choices);

$query = "Select lifemember from registrants where username = '" . $_SESSION[kt_login_user] . "'"; 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 

while($row = mysql_fetch_array($result))
{
    if ($row['lifemember'] == '1')
    {
        $_SESSION['MemberType'] = 'LifeMember';
    }
    else if($row['lifemember'] == '0')
    {
        $_SESSION['MemberType'] = '';
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:56:53+00:00Added an answer on May 18, 2026 at 1:56 am

    Precheck: If you are getting any ‘Headers already sent…’ then you have some output already on the page which is preventing the setting of session.

    Otherwise try debugging steps like:

    1) Do an echo $row['lifemember'] inside the while loop so that you know REAL value of what’s been fetched from DB.

    2) In else block, change it to $_SESSION['MemberType'] = 'Hello'; Then see, whether Hello is printed or not?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys really quick question, I have a simple test that I was doing
Hey guys, here's a weird question. I'm doing device detection and I noticed that
Hey guys. I have a method that gets called each second which I want
hey guys, I have an input field that looks for matched characters on a
hey guys, i'm getting an exception on the following inner exception: {Value cannot be
Hey guys i wrote a quick test. I want delete to call deleteMe which
Hey Guys, having an issue with Linq-to-SQL, I am basically doing the following but
Hey guys, I need to set a specific pixel in a texture to a
Hey guys, I have a little button functionality that is not erring, but also
Hey guys, I'm doing an ASP.NET MVC project just for learning...and stuck in this...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.