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 499569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:59:56+00:00 2026-05-13T05:59:56+00:00

I have a rough program sketched thusly: if (condition){ //redirect to some page }

  • 0

I have a rough program sketched thusly:

if (condition){
  //redirect to some page
}
else{
 echo $some_var;
}

So when I test is and the condition is true, it does the redirect, but also throws notices that there are undefined variables $some_var (that are pulled from a DB and WON’T be defined if the condition is true).

So does the code continue to evaluate after the if? This is not what I’ve expected.

If you want to dig, here’s the actual code (it’s CodeIgniter, but it’s mostly self-documenting) and the test case is a garbage “gift code” that’s not in the DB, so that count_all_results WILL == 0. The notices thrown are that $uses is undefined.

    $data['message'] = null;

    //seeing if code is valid
    $submitted_code = $_POST['code'];
    $this->db->where('code', $submitted_code);
    $this->db->from('codes');
    if ($this->db->count_all_results() == 0){
        $data['message'] = "This is not a valid gift code, sorry! You'll need to read our partner blogs, or listen to our favored Twitterers to find a valid code.";
        $this->load->view('submission_form_view', $data);
    }
    else {

    //seeing if code has any uses left
    $this->db->where('code', $submitted_code);
    $this->db->from('redemption_information');
    $used_so_far = $this->db->count_all_results();
    $this->db->select('uses');
    $query = $this->db->get_where('codes', array('code' => $submitted_code));
    foreach ($query->result() as $result)
    {
        $uses = $result->uses;
    }

    echo "Uses: $uses Used so far: $used_so_far <br />";

    if ($uses <= $used_so_far) {
        $this->load->view('over_used_view');
    }
    else
    {
    //these values are auto-escaped, so no worries on SQL injection
    if ($this->db->insert('redemption_information', $_POST)) {
        $data['message'] = "Your order has been taken, thanks for your interest!";
        $this->load->view('success_view', $data);
    }
    else {
        $data['message'] = "There was an error with your order. Please try again.";
        $this->load->view('submission_form_view', $data);
    }
    }
    }
  • 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-13T05:59:56+00:00Added an answer on May 13, 2026 at 5:59 am

    There’s a difference between parsing and evaluation. The notices you’re getting are parse notices (it’s parsing the variable in the else statement and not seeing a previous assignment, so it throws a notice), but the statement isn’t actually evaluated if the if condition is true.

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

Sidebar

Related Questions

I have written a multithreaded program which does some thinking and prints out some
Does anyone have a list of rough rule-of-thumb estimators for the various data structures?
I have some rough code for my project, and I am trying to get
I have a very rough workaround for 10 statements using a combination of 2
I have an issue with SQLAlchemy apparently committing. A rough sketch of my code:
I have made a program which is a small library operated via software. When
I have a rough php script that sees if a user has filled in
this is a rough idea of what my program looks like MainTabHost Activity (startup)
I have to write an XNA game for a project in my college program.
However, I am very new to django and lighttpd and have very rough idea

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.