PHP problem with include and $_GET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alex79
    Confirmed User
    • Jun 2002
    • 996

    #1

    PHP problem with include and $_GET

    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?
  • Nookster
    Confirmed IT Professional
    • Nov 2005
    • 3744

    #2
    http://us2.php.net/include/
    Look under "Example 16.7. include() through HTTP"

    when using include() and $_GET you must pull the included file with the complete url. And note that include with $_GET doesn't work with all configurations.
    The Best Affiliate Software, Ever.

    Comment

    • scouser
      marketer.
      • Aug 2006
      • 2280

      #3
      use file_get_contents - or yeah just use a complete url...
      Last edited by scouser; 02-03-2007, 11:16 PM.

      Comment

      • EDepth
        Confirmed User
        • Nov 2005
        • 510

        #4
        $id=@$_GET["xxx"]; <-- should be $_GET["id"] not xxx... but then yah no idea about passing vars to include files...
        ICQ: 275335837

        Comment

        • xenilk
          Confirmed User
          • Jan 2006
          • 921

          #5
          i don't think you grasp the concept of include yet.

          Why not just do

          $id = 'whatever';
          include('thefile.php');

          then in the 'thefile.php'
          if($id ... blabla)
          do some process here

          ... See an include as if the code would be litterally written where you include the file

          so if File1.php is
          $a = 1;
          $b = 2;
          include('File2.php');
          echo $c;

          and File2.php is
          $c = $a + $b;

          is equal to having a file with
          $a = 1;
          $b = 2;
          $c = $a+$b;
          echo $c;

          ... hope you see what I mean... 3am here, tired.
          40$/Page PSD->XHTML/CSS Transformations

          Comment

          • alex79
            Confirmed User
            • Jun 2002
            • 996

            #6
            ok..thanks everyboby

            Comment

            • woj
              <&(©¿©)&>
              • Jul 2002
              • 47882

              #7
              Originally posted by Nookster
              http://us2.php.net/include/
              Look under "Example 16.7. include() through HTTP"

              when using include() and $_GET you must pull the included file with the complete url. And note that include with $_GET doesn't work with all configurations.
              don't do that, that's lame, and will just unnecessarily slow the page down...

              do something like this:

              $id='xxx';
              include("/path/to/file.php");

              then inside file.php just use $id wherever needed...
              Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
              Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
              Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

              Comment

              Working...