Including a page w/ GET arguments

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have a page that returns data based on the arguments provided to it
in the URL.  I want to show these results embedded in another page.
Include('mypage.php?name=joe') fails with "failed to open stream:
Invalid argument".  How can I do this?



Re: Including a page w/ GET arguments wrote:
Quoted text here. Click to load it

The file name is not 'mypage.php?name=joe', is it?  That is, do you see  
that in your directory listing?

When you use GET parameters, the web server strips them out before  
fetching the file.  include() does not such thing.

Include just copies the included file into the location in your existing  
file, just as if you had cut and pasted it.  So, if you have:


Within mypage. php you can just reference $name and get 'joe'.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Including a page w/ GET arguments

On Mon, 13 Mar 2006 23:23:40 -0500, Jerry Stuckle wrote:
Quoted text here. Click to load it

You're probably better off adding name to $_GET so the same code
can work regardless of which way mypage.php is being called (on it's own
or through this page).

$_GET['name'] = 'joe';

Or (just for completeness, it's slower) you could do:


(this involves apache so would register an extra hit on your site and be
slower as it would involve a separate PHP instance).



Andy Jeffries MBCS CITP ZCE   | gPHPEdit Lead Developer | PHP editor for Gnome 2 | Personal site and photos

Re: Including a page w/ GET arguments wrote:

Quoted text here. Click to load it
As has been said, you simply do not need add the variable. It is already  
in the local environment and the include file can access it directly.

Read the first note (and example) here about variable scope:

 Chuck Anderson • Boulder, CO
 Integrity is obvious.
 The lack of it is common.

Site Timeline