Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to using INCLUDE with query url?

Status
Not open for further replies.

warik

Programmer
Jun 28, 2002
169
ID
Dear all,

I have a script like this :


<?
echo &quot;The page<p>&quot;;
include('/home/public_html/show.php&quot;);
?>


and it work.

The problem is, the script can not work if I use query at include script.


include('/home/public_html/show.php?action=list&quot;);


Well, maybe it can not use include for query, so pls help me to solve this problem.

Thank you in advance.
 
That's because &quot;?action=list&quot; is meaningful only in the context of accessing the file through a web server. Include() brings in content from the filesystem.

But you don't need &quot;?action=list&quot;. Code in an included file inherits the variable scope of the point in which it is invoked by include(). Just reference the variable in question from within the included script.


If you need to access the output of another script as it is run under a web server, fopen (' 'r') will work, provided your version of PHP is version 4.x and the runtime configuration directive &quot;allow_url_open&quot; is set to &quot;on&quot;. You can then access that script's output as though it is a file. Want the best answers? Ask the best questions: TANSTAAFL!
 
Warik, to go back to your first example, I think that it would work in this way, as suggested by Sleipnir214:

<?
echo &quot;The page<p>&quot;;
$action=&quot;list&quot;;
include('/home/public_html/show.php&quot;);
?>

Gaetano

 
warik:

fopen() is used to open a file and provide a file handle. To produce output, you must fetch data from the handle and output it. Take a look in the PHP online manual under fread() or fgets().

But as casters has pointed out, and to provide a more general solution, the followinging:

$_GET['action'] = 'list';
include('/home/public_html/show.php');

should also accomplish the same thing. Want the best answers? Ask the best questions: TANSTAAFL!
 
Casters and Sleipnir,

Well, I think I got the solution for my problem. Thank you for your all informations guys. It really helpfull to me.

Thank's
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top