Log in

View Full Version : Complex include of global.php


BenSkiddle
03-13-2005, 05:59 PM
Hi

We have some pages that already use a database connection and include several functions files.

I have tried including global.php but whatever method (chdir etc) I use gives errors..

Here's what I have on the page so far..

<? session_start();
require("db/connectguidedb.php");
require("cobrand.php");
require("checklogin.php");
require("../cms/functions/listings.php");
require("functions.php");
require("../member/functions/premiummembers.php");
//rest of page here
?>


The checklogin file has:

$cwd = getcwd();
chdir("../forum/");
require('global.php');
chdir($cwd);


this gives:


Warning: chdir(): No such file or directory (errno 2) in /home/xxxx/public_html/whatson/checklogin.php on line 4

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxxx/public_html/whatson/functions.php on line 43
Invalid Request

I have also tried the following in checklogin.php:

$intDirPos = strpos($_SERVER['SCRIPT_NAME'],"/",1);
$strDirectoryCurrent = substr($_SERVER['SCRIPT_NAME'], 1, strpos($_SERVER['SCRIPT_NAME'],"/",1)-1);
if($intDirPos!==false)
{ // we are calling from a sub directory
chdir("../forum");
include("global.php");
chdir("../".$strDirectoryCurrent);
}else{ // we are calling from the web root directory
chdir("./forum");
include("global.php");
chdir($cwd);
}


Which gives the following error:

Warning: main(../cms/functions/listings.php): failed to open stream: No such file or directory in /whatson/guide.php on line 5

Anybody got any ideas - its a total arse!

DRJ
03-13-2005, 06:00 PM
Try this

chdir("..");
chdir("./forum/");

Marco van Herwaarden
03-13-2005, 06:04 PM
It seems you $cws don't get filled ok.

Maybe a stupid question, i asume you have a "<?php" in the top and a "?>" in the bottom of your checklogin file?

BenSkiddle
03-14-2005, 05:45 PM
If I echo the $cwd variable I get something like:

/home/***/public_html/whatson

which seems ok?