how do I make blah.php?id=home.php work
Posted: Fri Feb 13, 2004 12:52 pm
how do I get the function mentioned to work. I have no idea how it is done, is it something to do with include($id.php) or something
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
$id = GET['id'];
include('index.php?id=' . $id . '.php');
?>Code: Select all
<a href="index.php?id=edit">Code: Select all
index.php
<?
if(!isset($id)){
include('/home/oblivion/public_html/site/blog/index.php');
}
else
{
for($i=0; i<count($links); $i++)
{
if($id==$links[$i])
{
include($url[$i]);
break;
}
}
}
?>Code: Select all
include('index.php?id=' . $id . '.php');Code: Select all
include('2.php?id=anything'); //<<Line 3Code: Select all
Warning: main(2.php?id=anything): failed to open stream: No such file or directory in O:\Program Files\Apache Group\Apache2\htdocs\tests\test2.php on line 3
Warning: main(): Failed opening '2.php?id=anything' for inclusion (include_path='.;c:\php4\pear') in O:\Program Files\Apache Group\Apache2\htdocs\tests\test2.php on line 3And i'm saying that wont work... php.net agrees with me too!!voodoo9055 wrote:Code: Select all
<?php $id = GET['id']; include('index.php?id=' . $id . '.php'); ?>
Code: Select all
<?php
/* This example assumes that http://www.example.com is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */
// Won't work; file.txt wasn't handled by http://www.example.com as PHP
include 'http://www.example.com/file.txt?foo=1&bar=2';
// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
// local filesystem.
include 'file.php?foo=1&bar=2';
// Works.
include 'http://www.example.com/file.php?foo=1&bar=2';
$foo = 1;
$bar = 2;
include 'file.txt'; // Works.
include 'file.php'; // Works.
?>