Is It Possible to pass a variable through an included file


i tried it but it says : Failed to open stream: No such file or directory

plz i need help and if it's not possible how can i pass this variable

I think we don't need to pass a variable to an included file, it already has
access to all variables in the including script. It becomes part of the
script that is including it.

$page = 'partner';
include '../admin/addcustomer.php';

Now addcustomer.php will see that $page contains 'partner'.

No,Thats not the case in my script
i have a file called links this file contains a switch statement and i need to send this variable to that file addcustomer
i also tried your way but it not working
the file didnt recognize that page variable

Is the included file just basic PHP, or does it have classes/functions in it, if the file uses functions you may need to register the variable as a global variable within each function you want to use it in.

Otherwise, post up your code so we can see what you are doing.

/***  The Links script called adminlinks.php***/

$action=$_GET['action'] ;

switch ($action) {

case "partner_company":

  include ("../admin/addcompany.php?page=partner");


 /********** The AddCompanyScript *********/

        else $flag=0;
  /******   Index2.php***********/

            {<? include("includes/adminlinks.php") ;?> }

 /***********AddPartner Script******/





I know this is a little bit complicated But Here the Storyboard ::)
i got a table called partners by which the admin can add a partner ..this partner can be an individual or can be a company i made the admin choose before adding whether he wants to add a partner or a partner_company so if the last was the case he should be directed to the addcompany script BUT with a variable called page=partner

Edited 3 Years Ago by Dani: Formatting fixed

Try this in your switch statement:

switch ($action)

	case "partner_company":
	$_GET['page'] = 'partner'; // Define the page - variable will then be available in addcompany.php
	include ("../admin/addcompany.php");
Good teaching others...keep it up...
This question has already been answered. Start a new discussion instead.