php include file problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
devstar
Forum Newbie
Posts: 3
Joined: Tue Mar 13, 2007 10:39 pm

php include file problem

Post by devstar »

Hi

i have a base file and another file is included in it. that included file has another include file.
second include file has some database connections. but i am not able to call functions in the second include from my base file.
when i try to pring $_SERVER['PHP_SELF'] from my first include file it prints the base file name. but when i tried it from the second include it prints its own path.
but this setup is working fine on linux machines.
corrently iam working on windows xp,iis, php 4.4 and mysql 4.1.9.

please help.

thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post your code.

If they are long make examples that do the same thing, but in a much more confined space.
devstar
Forum Newbie
Posts: 3
Joined: Tue Mar 13, 2007 10:39 pm

Post by devstar »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


my_home.php -----base file content

Code: Select all

<?php
	include _ROOT_PATH_."myxt_includes/userheader.htm";
?>
userheader.htm ---- file content

Code: Select all

<?
include_once ( _ROOT_INCLUDE_PATH_."myxt_includes/pageconfig.php");
echo eregi_replace(".php$","",$_SERVER['PHP_SELF']); //---here it prints path to my_home.php 
?>

pageconfig.php ---- file content

Code: Select all

<?
echo eregi_replace(".php$","",$_SERVER['PHP_SELF']); //---here it prints path to pageconfig.php
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What is _ROOT_INCLUDE_PATH_ set to?
devstar
Forum Newbie
Posts: 3
Joined: Tue Mar 13, 2007 10:39 pm

Post by devstar »

define ('_ROOT_INCLUDE_PATH_','http://localhost/xtimeaus/'); //this is the wesite root path

and

define ('_ROOT_PATH_', strrev(strstr(strrev($_SERVER['SCRIPT_FILENAME']),DIRECTORY_SEPARATOR)).'../'); //this is defined in every base files.

ie, mycxc_home.php here.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

http:// quantifies as a remote request to PHP. This is why your code involving PHP_SELF works differently and why you cannot use any of the code in the file.
Post Reply