GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP problem with include and $_GET (https://gfy.com/showthread.php?t=702750)

alex79 02-04-2007 01:08 AM

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 02-04-2007 01:14 AM

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.

scouser 02-04-2007 01:15 AM

use file_get_contents - or yeah just use a complete url...

EDepth 02-04-2007 01:17 AM

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

xenilk 02-04-2007 01:18 AM

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.

alex79 02-04-2007 01:28 AM

ok..thanks everyboby

woj 02-04-2007 01:31 AM

Quote:

Originally Posted by Nookster (Post 11854591)
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...


All times are GMT -7. The time now is 08:46 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123