Jump to content

Two codes at the very top conflicting


Broleta

Recommended Posts

Hello, I have encountered a problem with my website. I am trying to use two separate mods/addons for vbulletin to display news from a forum and a login panel respectively. The problem is that both scripts require me to add a code at the "very top" of my website php file. I have tried adding one after the other with no success. I have tried using includes to include the scripts and adding the top codes to them instead but this does not work.

 

The top codes are:

For the news script:

<?php

chdir('./forums');

require_once('./vBExternal.php');

?>

 

For the login panel script:

<?php

$curdir = getcwd ();

chdir('forums');

require_once('forums/global.php');

chdir ($curdir);

?>

 

Link to comment
https://forums.phpfreaks.com/topic/112331-two-codes-at-the-very-top-conflicting/
Share on other sites

<?php
error_reporting(E_ALL ^ E_NOTICE);
$curdir = getcwd ();
chdir('./forums');
require_once('./vBExternal.php');
chdir ($curdir);
chdir('forums');
require_once('forums/global.php');
chdir ($curdir);
?>

 

 

Try this and tell me if any errors are displayed.

Nope no errors still just a blank page.

I recommend you to do somehting like the following when dealing with includes:

define('ROOT', $_SERVER['DOCUMENT_ROOT']);

require_once ROOT . '/forums/vBExternal.php';
require_once ROOT . '/forums/globals.php';

 

Seems you are overcomplicating things with chdir.

 

$_SERVER['DOCUMENT_ROOT'] returns the absolute path to your sites root. This will tell PHP to include files from the root rather than the current working directory.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.