Question

My config file looks like this:

<?php
define('ROOT_DIR', dirname(_FILE_));
?>

then my html:

<?php 
require_once ('../../../../config.php');  // back to app root
?>

<?php
$pageTitle = 'title';
require_once(ROOT_DIR.'includes/content.php');
?>

I know my config file is loading because I can see my config comments when I view source.

But, otherwise I'm just getting a blank page. Anyone tell me what I'm doing wrong?

EDIT:

Error Reporting yields

Warning: require_once(./includes/content.php) [function.require-once]: failed to open stream: No such file or directory in /Applications/MAMP/html/BLX2012/prototypes/19/demo.16/events/2013/PIC/LasVegas/index.php on line 10

Fatal error: require_once() [function.require]: Failed opening required './includes/content.php' (include_path='.:/Applications/MAMP/bin/php/php5.3.6/lib/php') in /Applications/MAMP/html/BLX2012/prototypes/19/demo.16/events/2013/PIC/LasVegas/index.php on line 10

[Sorry I wish the above were more readble]

Was it helpful?

Solution

_FILE_ should be __FILE__ (2 underscores on each side).

So your ROOT_DIR constant is being set wrong, and PHP doesn't know where to look.

OTHER TIPS

you're missing a / in: require_once(ROOT_DIR.'includes/content.php');

Change it to: require_once(ROOT_DIR.'/includes/content.php');

At the beginning of your script, add this statement to see if you get any errors:

ini_set('error_reporting', E_ALL);

Is it possible that content.php includes a file in a wrong path?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top