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 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

I have a header file variable.h where i declare all my global variable.Then i
in my program I have undefined variable somewhere: global name 'cmd' is not defined
If i have global variable in A.dll, that depends on global variable in B.dll
I have a global variable that is an instance of my custom class. How
I have a global pointer variable char* pointer = new char[500]; /* some operations...
If I have a global static variable x like in this code #include <stdio.h>
In following program . I have one doubt. I have declared one global variable
I have used a static global variable and a static volatile variable in file
I have a vector declared as a global variable that I need to be
I have a python module that makes use of a huge dictionary global variable,

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.