problems with an include statement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cmadsen
Forum Newbie
Posts: 3
Joined: Fri Aug 04, 2006 6:54 pm

problems with an include statement

Post by cmadsen »

I am having problems with the following include statement and I know I am overlooking something.

include ('images.php?TypeID='.$typeID.'&ListingID='.$listingID);

This is the error i'm getting. I'm not pulling the last parameter. I put a print $listingID right before this line and the variable printed fine.

Warning: main(images.php?TypeID=42&ListingID=): failed to open stream
Tom420
Forum Newbie
Posts: 15
Joined: Sun Aug 13, 2006 1:50 am
Location: Sherbrooke, Québec, Canada

Post by Tom420 »

You can't pass parameters this way when including a file.

instead of:

include("test.php?var=value");

do:

$var = 'value';
include("test.php");

or, if test.php expects a get:

$_GET['var'] = 'value';
include("test.php");

Hope this helps,
Tom :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

include() and its sibling require() use the file system. URL-like query strings aren't supported. The requested script will have access to any previously defined variables.
Post Reply