Jump to content


Photo

Calling pages contents using include


  • Please log in to reply
5 replies to this topic

#1 mvosoughi

mvosoughi
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 07 March 2006 - 10:45 AM

Hi, is there any difference between calling pages contents between PHP on Apcahe versus PHP on IIS? My problem is under PHP/Apache I used include command to call in pages contents (index.php?page=2) but under PHP/Windows platform, it cannot pass the page contents or page title and it only calls the page=0 contents.

As I said, my codes works under PHP/Apache and I have no problem calling in the contents of each page using switch statement ...

Any ideas how to solve this problem?

Here is a sample of my codes:
----------------
index.php
---

<?
include "contents.php";
?>

<?
include "pages/$content";
?>
-----------------
contents.php
---
<?
switch ($page)
{
case 0:
$content = "main.php";
$title = "Main";
break;

case 1:
$content = "page2.php";
$title = "Page two";
break;
?>



#2 Toni_montana

Toni_montana
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 07 March 2006 - 11:29 AM

I'm not sure wheter this is gonna solve your problem,

But i think it's better to use

$page =$_GET['page'];

over just asuming that $page will contain the variable passed by GET. I don't think that the way you do it is supported by all OS.

good luck

rogier

#3 mvosoughi

mvosoughi
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 07 March 2006 - 11:31 AM

[!--quoteo(post=352457:date=Mar 7 2006, 11:29 AM:name=Toni_montana)--][div class=\'quotetop\']QUOTE(Toni_montana @ Mar 7 2006, 11:29 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I'm not sure wheter this is gonna solve your problem,

But i think it's better to use

$page =$_GET['page'];

over just asuming that $page will contain the variable passed by GET. I don't think that the way you do it is supported by all OS.

good luck

rogier
[/quote]


Thank you Toni_montana

But that was not the problem I was explaining.

#4 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 07 March 2006 - 12:14 PM

have you tryed using require for the first one? not sure if that will treat it diffrent.. maby worth doing an echo after each case "case1"; echo "case2";... to see how far your code is getting.. do you get any errors?
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#5 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 07 March 2006 - 12:39 PM

Melv!

Tony was correct!

It appears that your installation on windows has register_globals turned off - which it should be these days anyway (hope they remove that config option in future versions).

if you are passing through the url like you say (index.php?page=1) then BEFORE you include contents.php define $page by...

$page = $_GET['page'];

$page will be 0 (or false or even unset) unless you do so.


follow me on twitter @PHPsycho

#6 mvosoughi

mvosoughi
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 07 March 2006 - 01:18 PM

Than you Toni_montana and ToonMariner,

You both were right. That acutally solved the problem.

Mel





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users