# PHP question



## Browni (Jan 12, 2005)

Right, i would like the simplicity of a iframe situation with changing content e.g. click link in nav bar, and it appears in main section, but in PHP, i know how to use the <?php include ('filename.html') > is there any way i can specify that a area of the page is called 'content' and point a file to to display in that area? like the way Mabmbo OS does it (and many other CMS's)\

Browni


----------



## andehlu (Jan 12, 2005)

Im assuming you mean without reloading the whole page right? If so, not really no. Youd either have to use frames, iframes or div's. DIV's using css visibilty is a wicked way of doing this but the issue is that you need to load the content of all divs on page load, you cannot load any external files into divs. 

Php is a server side language so the whole page has to be reloaded fromthe server is order to have an include work properly. Easiest way to do what you want is using an iframe (if you want to load external files.)

This is how I built my site


----------



## Browni (Jan 13, 2005)

ok thanks, have to look into URL Cloaking <<calls Hosting People>>


----------



## Arden (Jan 14, 2005)

What you're describing is completely possible, but not if you don't want to reload the entire page, like andehlu said.  If you would like me to collaborate with you and try to figure out a solution, send me an IM; my screen name's in my profile.


----------



## garymum4d (Jan 20, 2005)

I have the same problem as Browni but i'm not bothered if the whole page reloads. the code i'm using is: in the area i want the content to appear:

          <?php if (!$t) {
				include("home.php");
				} else {
				include($t);
				}?>

And on the nav bar button:

<a href="?t=creative.php">

and so on.

This is working fine on my Mac at work, BUT if I upload it to my ISP or even put it onto any another Mac on the network or at home, it does not work at all. Anyone have anyi deas why?

to see an example go to sample I have only coded the first 2 buttons in the nav bar so far. I can assure you this works perfect on my Mac at work.

If i cannot get this to work, then, How do I use iFrames???

Thanks in advance


----------



## Arden (Jan 21, 2005)

They probably have Register Globals turned off.  Try if(!$_GET['t']) instead.  Or, declare beforehand: $t = $_GET['t'];


----------



## garymum4d (Jan 21, 2005)

Arden said:
			
		

> They probably have Register Globals turned off.  Try if(!$_GET['t']) instead.  Or, declare beforehand: $t = $_GET['t'];


Arden. 
THANKS, this works fine now. You are a superstar!!!!!


----------



## garymum4d (Feb 3, 2005)

A question for Arden (or any other php coder that can help)

I used the code Arden sugested on a site and it works perfect. Now I have used the same code (well almost the same, changed t for x) on another site. the code works fine BUT the server that hosts it has a high level of reporting turned on and I get the following message appear:

*Notice: Undefined index: x in E:\web\trix-ltd\matrix\index.php on line 92*

line 92 is the first line of the following php code"

*<?php if (!$_GET['x']) {
				include("home.php");
				} else {
				include($x.'.php');
				}?>*

The ISP will not turn reporting off. Is there any way to stop this from appearing??

the site it's on is 
www.matrixfm.com 

THANKS


----------



## aicul (Feb 11, 2005)

Try intercepting and managing the error yourself.


```
error_reporting(); 
set_error_handler(myError);
```

Put the above code in your php and write a function called myError to act on the error message. 

In think that in your example the 
	
	



```
include($x.'.php');
```
 is causing the problem as variable $x is undefined.


----------



## neph (Feb 14, 2005)

aicul is correct.  When you say:


```
$_GET['x']
```

...it's throwing an error, because there is no 'x' index in $_GET.  What you want to do is trap that.  Here's what I would do:


```
$page_to_display = isset($_GET['x']) ? $_GET['x'] : 'home';
  include( $page_to_display . '.php' );
```

What this does is first check if there is an 'x' index set in $_GET.  If there is, it uses it.  Otherwise, it uses 'home'.  Once you have that, you can use it to do your include.


----------

