Problem with include and $_GET

Discussion in 'PHP' started by jalex, Feb 4, 2007.

  1. #1
    I want make include of a file with variables like:

    include("/path/to/file.php?id=xxx");
    in file.php i get the id variable with $id=@$_GET["xxx"];

    the problem is that variable are not passed.. for $_GET i get a null value..

    what can i do to pass the variable id to file.php through include function?
     
    jalex, Feb 4, 2007 IP
  2. abixalmon

    abixalmon Well-Known Member

    Messages:
    378
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    120
    #2
    You cannot use include to use a file with variable passed..

    use it this way:

    $variable = "xyz";
    include("/path/to/file.php");

    In the include file "file.php"

    use the variable $variable,

    This will work!
     
    abixalmon, Feb 4, 2007 IP
  3. jalex

    jalex Active Member

    Messages:
    184
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    ok..thanks
     
    jalex, Feb 4, 2007 IP
  4. oziman

    oziman Active Member

    Messages:
    199
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #4
    I think you have to declare $variable as global in file.php, no?
     
    oziman, Feb 4, 2007 IP
  5. Icheb

    Icheb Peon

    Messages:
    1,092
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #5
    rofl, good joke.
     
    Icheb, Feb 4, 2007 IP