Page 1 of 1

php include file problem

Posted: Wed Mar 14, 2007 12:06 am
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.

Posted: Wed Mar 14, 2007 12:27 am
by feyd
Post your code.

If they are long make examples that do the same thing, but in a much more confined space.

Posted: Wed Mar 14, 2007 12:36 am
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]

Posted: Wed Mar 14, 2007 12:39 am
by feyd
What is _ROOT_INCLUDE_PATH_ set to?

Posted: Wed Mar 14, 2007 12:55 am
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.

Posted: Wed Mar 14, 2007 12:57 am
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.