Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

142 users online



Tutorial: page.php?page=blah / query strings / easy template tutorial (UPDATED)

Tutorial: page.php?page=blah / query strings / easy template tutorial (UPDATED)

Currently viewing this thread: 1 (0 members and 1 guests)


Page 9 out of 15
dafrabbit

dafrabbit

Neverside Newbie
Status: Offline!

Uhh, it shouldn't give you a 404 error.....that's kind of weird. Jaded is right about your downloads error though.

Phil

Phil

with Mr. Jones
Status: Offline!

opening in a dir above your current one may give basedir errors depending on server config, so watch out for that.

___________________

http://www.philbrodeur.com - Expert PHP Development and Tutorials

Morpheus

Morpheus

Status: Offline!

I also bumped into a similar error even though the directory and the file all exist. If i type in the URL for the gallery directly (http://www.my-site.com/gallery) on the address bar, the gallery loads perfectly. But since I want it included in the site layout, the error comes up. By the way, the gallery is its own sub-folder

I then tried putting in the direct URL (http://www.my-site.com/gallery) into the switch statement and even tried the direct linking from the host ( /home/my-site/public_html/gallery) but nothing seemed to work.

The last resort I thought would do the trick was to have the gallery load inside an I-Frame but that didnt work either Sad

The error was:

Warning: main(): stream does not support seeking in /home/mysite/public_html/index2.php on line 72

PHP:


<?
if (!isset($_GET['link_id']) )
{
 
 include 
'index2.php';
}
else
{
 switch (
$_GET['link_id'])
 { 

 case 
"music":
 include 
'music.php';  //<---- A page like this one loads well 
 
break;

 case 
"gallery":
 include 
'gallery/index.php';  //<---- But this has an error. I dunno if its due to the sub-directory 
 
break;

 default:
 include 
'index2.php';
 
 } 
// end switch
// end else if
?>

Motorspin

Motorspin

Neverside Newbie
Status: Offline!

include ('./gallery/index.php');

___________________

Travis Farrell
http://motorspin.com/stuff/images/avasig/m_enterprisesig.gif

m3th

m3th

Status: Offline!

just do this

PHP:


<?php
$page 
$_GET['article']
    if(
IsFile($page) {
        include(
"$page" ".php");
    } else { 
    echo(
"Not a file");
}
?>

___________________

<?php
$var="Working on my sig :-P";
echo =$var;
?>

fredmv

fredmv

Status: Offline!

I think the function you are actually looking for is is_file.

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

Motorspin

Motorspin

Neverside Newbie
Status: Offline!
PHP:

<?php

if(is_file($page))

  include(
$page); 

else
{
  echo 
'Not a valid file.';
}

?>

I hoped you typed that on the fly because it was full of errors. Plus if you're checking the variable if it's a file, it's got an extension already, so you don't need to add it again.'

EDIT: The way I was looking at it made it look like it was full of errors, un-neatness has weird effects on the eye.

___________________

Travis Farrell
http://motorspin.com/stuff/images/avasig/m_enterprisesig.gif

Last edited by Motorspin, September 21st, 2003 01:54 AM (Edited 1 times)

arthaus

arthaus

Marathon Runner
Status: Offline!

Re: Tutorial: page.php?page=blah / query strings / easy template tutorial (UPDATED)

Hi Ares,

I'm using the method listed below here.

PHP:


<?php

if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] == 'news') {
     include 
'pages/news.php';
}
if(isset(
$_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] == 'portfolio') {
     include 
'pages/portfolio.php';
}
if(isset(
$_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] == 'forum') {
     
header("Location: forum.php");
}
?>

If a user types ../revised/ I would like it to go to --> ../revised/?studio ...which is the entrance home page.

Q: Do I have to use else method?

Thankx in advance,
Arthur

Phil

Phil

with Mr. Jones
Status: Offline!

You mean if one goes with no query string? do something like

if(!isset($_SERVER['QUERY_STRING'])) {
include 'pages/studio.php';
}

on the page that revised/ goes to.

You should use switch; its faster. I think I got a example in topic post.

___________________

http://www.philbrodeur.com - Expert PHP Development and Tutorials

arthaus

arthaus

Marathon Runner
Status: Offline!

Hi Ares,

No. I don't have studio.php file.
The code i'm using listed below...

PHP:


<?php 
if(isset ($_SERVER ['QUERY_STRING']) && $_SERVER ['QUERY_STRING'] == 'filler') {
    include 
'inc/filler.inc.php';
}
if(isset (
$_SERVER ['QUERY_STRING']) && $_SERVER ['QUERY_STRING'] == 'portfolio') {
    include 
'inc/portfolio.inc.php';
}
if(isset (
$_SERVER ['QUERY_STRING']) && $_SERVER ['QUERY_STRING'] == 'contact') {
    include 
'inc/contact.inc.php';
}
if(isset (
$_SERVER ['QUERY_STRING']) && $_SERVER ['QUERY_STRING'] == 'studio') {
    include 
'inc/studio.inc.php';
}
?>

However, if you go here, without query string, partial page is displayed (since the query string includes the content).

Regards,
Arthur

Page 9 out of 15
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0121 seconds.