how do I make blah.php?id=home.php work
Moderator: General Moderators
-
andylyon87
- Forum Contributor
- Posts: 168
- Joined: Sat Jan 31, 2004 5:31 am
- Location: Dundee
how do I make blah.php?id=home.php work
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
- voodoo9055
- Forum Commoner
- Posts: 51
- Joined: Sat Apr 26, 2003 3:27 pm
- Location: Montgomery, AL
Code: Select all
<?php
$id = GET['id'];
include('index.php?id=' . $id . '.php');
?>Code: Select all
<a href="index.php?id=edit">- voodoo9055
- Forum Commoner
- Posts: 51
- Joined: Sat Apr 26, 2003 3:27 pm
- Location: Montgomery, AL
-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
Heres how I do it..
And then I make two arrays one called $links and the other called $url and it works great..
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;
}
}
}
?>-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
correct me if im wrong, but you can't do an include like this:
Code: Select all
include('index.php?id=' . $id . '.php');-
seeker2921
- Forum Contributor
- Posts: 120
- Joined: Sat Mar 22, 2003 7:10 pm
- Location: Wiesbaden Germany
- Contact:
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
well, do you have to turn something on/off because anytime i do an include() like
i get these errors:
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 3-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
i dont want to do that. But thats what voodoo9055 said to do:
http://us2.php.net/function.include
And 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'); ?>
http://us2.php.net/function.include
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.
?>-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
include 'index.php?id='.$id; //won't work
include "index.php?id=$id"; //won't work
include 'http://localhost/index.php?id='.$id; //will work
include "http://localhost/index.php?id=$id"; //will work
include "index.php?id=$id"; //won't work
include 'http://localhost/index.php?id='.$id; //will work
include "http://localhost/index.php?id=$id"; //will work
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
- voodoo9055
- Forum Commoner
- Posts: 51
- Joined: Sat Apr 26, 2003 3:27 pm
- Location: Montgomery, AL