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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:11:40+00:00 2026-05-16T20:11:40+00:00

I am trying to pass a variable to a included file. I have done

  • 0

I am trying to pass a variable to a included file. I have done something like this:

$id = $_GET['id'];
include('myfile.php');

And the file ‘myfile.php’ contains a form and a submit button. It’s processing page is ‘process.php’ and in it, I have done:

$_id = var_dump($id);

// insert query

But I did not get the value of the variable, so 0 is inserted into the table.

Is there any other simpler way of doing it?

Thanks!

  • 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-16T20:11:40+00:00Added an answer on May 16, 2026 at 8:11 pm

    Functions.

    Have myfile.php declare a function (e.g. myfunction), which you call in the including script.

    For example:

    // main.php
    <?php
    
    include('myfile.php');
    
    process_data($_GET['id']);
    
    // myfile.php
    <?php
    
    function process_data($id) {
        $query = 'SELECT * FROM foobar WHERE id = ' . mysql_real_escape_string($id);
    
        // ...
    }
    

    If you really want to pass the variable as a global, and you’re referencing the global in a function or method, be sure to reference it as $GLOBALS['varname'] or to use global $varname:

    function process_data() {
        $id = &$GLOBALS['id'];
        // or
        global $id;
    
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use AMF PHP to pass variables to a flash file,
I'm trying to use node_load to pass php variables (as variables!) from one node
I'm trying to pass variables using get in php, but ran into a snag.
I'm trying to find a good way to maintain PHP configuration differences between a
I'm having trouble deciding whether not this code should compile or if just both
I'm trying to compile GNUstep on a linux box but gnustep-gui-0.16.0 package is failing.
I've got some Jquery functions that I keep in a custom.js file. On some
Hey guys, I'm trying to compute the cumulative distribution function of the standard normal
Is it possible to make php variables public and accessible anywhere on the timeline?
Thanks for reading this. I imagine this is really a javascript question, and my

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.