473,382 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Including a page w/ GET arguments

Hi

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?

Thanks

IWP506

Mar 14 '06 #1
3 5655
IW****@gmail.com wrote:
Hi

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?

Thanks

IWP506


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:

$name='joe';
include('mypage.php');

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

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 14 '06 #2
On Mon, 13 Mar 2006 23:23:40 -0500, Jerry Stuckle wrote:
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:

$name='joe';
include('mypage.php');

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


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';
include('mypage.php');

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

include("http://myhostname/mypage.php?name=joe");

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

Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Mar 14 '06 #3
IW****@gmail.com wrote:
Hi

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?

Thanks

IWP506

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:
http://www.php.net/manual/en/languag...bles.scope.php

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Mar 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Theo | last post by:
Just a quick question... When including a page inside another (include('page.php')), is it bad for the second document to also have <head> and <body> tags etc? Im using iframes currently, and it...
8
by: David D. | last post by:
In html, one can say <script language="JavaScript" src="http://someCodeSnippet.js"> Is there any way to embed the included code snippet in a function (in the case where it is not already a...
6
by: IWP506 | last post by:
I know the subject is a bit confusing, but I really need to know if this is possible. I've got a php page. Let's call that a.php In a.php, I make a call to a webpage (b.php), with some...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
1
by: Liz | last post by:
I have a page with several dropdownlists, several text boxes and several buttons which perform calculations. I need to validate one dropdownlist (not the whole page) with the click of one button. I...
5
by: Chris Ashley | last post by:
Hi there, I need to include an ASPX page within an ASP page. Is this possible? EG: making-a-claim.asp is: <!-- #include file="top.asp" -->
38
by: Neo Geshel | last post by:
I am seeking a method to load one JS file directly into another, *without* having to dynamically write <scripttags. Is there any method whereby I can call only one external JS file using a ...
2
by: defyinggravity | last post by:
Hi this is a newbie alert! This may seem really basic to most, but I am a total beginner, so please don't laugh, or gif me false info...lol I will use it. I have an ajax container loading on my...
10
by: Robert Huff | last post by:
Can someone offer suggestions why, on the same server (Apache 2.2.8), this works <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html lang="en-US"> <head> <link rel=stylesheet...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.