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

  • Home
  • SEARCH
  • 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 6092097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:24:12+00:00 2026-05-23T12:24:12+00:00

I have a global variable being changed in if statement then accessed in else,

  • 0

I have a global variable being changed in if statement then accessed in else, but it does not have the same value and loses its value:

global $reqUserID;
    if ($_SERVER['REQUEST_METHOD'] == 'POST'){

        if (isset($_POST['viewReq'])) {

            $requests = new requests();
            $results = $requests->getRequest($_POST['reqID']);

            $result = mysql_fetch_array($results, MYSQL_ASSOC))

            $GLOBALS['reqUserID'] = $result['USER_ID']; //CORRECT VALUE HERE

        }
        else if (isset($_POST['approveBtn'])) {

            $var1 = $GLOBALS['reqUserID'];
            $sql = "SELECT EMAIL FROM user_info WHERE USER_ID='$var1'";//SOME OTHER VALUE HERE
            [...]
        }
  • 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-23T12:24:12+00:00Added an answer on May 23, 2026 at 12:24 pm

    page was being posted to itself, and Global variable involved was not being posted to be used, so i made a hidden field filled it with the value of global variable on the first pass and posted the value and used it late using _POST array.

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

Sidebar

Related Questions

VB 6.0 does not have any global handler.To catch runtime errors,we need to add
I have used a static global variable and a static volatile variable in file
I have a python module that makes use of a huge dictionary global variable,
Say I have a global variable INT named X. Since X is global, we
I have a recursion function that parses an object/array with a global variable. If
I have some global variables in a Python script. Some functions in that script
Hey right now I'm using jQuery and I have some global variables to hold
I have a big list of global variables that each have their own setup
I have a javascript function (function1) that checks some global variables (can the user
I'm having trouble with global variables in php. I have a $screen var set

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.