1

I've transferred a PHP web-system from a Windows hosting provider to a Linux based hosting service.

In the system's scripts, when it comes to require_once, the script simply stops and leaves the user at a blank white page.

I've tried both of the below:

Try 1

require_once($_SERVER['DOCUMENT_ROOT'] . '\library\data\Dbec.php') or die("could not load file");

Try 2

require_once(dirname(__FILE__) . '/library/data/Dbec.php') or die("could not load file");

In both cases, the text in the die parenthesis is not showing and the page remains blank. The script that is requiring the above files is in '/library/membership/theScript.php'

Based on the reading I've done on line up to now, maybe it has to do with changing the include_path in php.ini file or writing the paths in a different way.

If its any of the above, or something different, I'd appreciate some hints.

user229044
  • 232,980
  • 40
  • 330
  • 338
Nick
  • 53
  • 2
  • 5
  • Can you take a look at the server logs? – Ansari May 29 '12 at 19:39
  • is there anything above that line in the code? perhaps an earlier error is causing the page to die before that line is reached – Matt Dodge May 29 '12 at 19:40
  • Well the second wont work then because `dirname(__FILE__)` is going to be `/path/to/document/root/library/membership`... – prodigitalson May 29 '12 at 19:42
  • Try setting a variable equal to the file path and echoing it before. `$path = $_SERVER['DOCUMENT_ROOT'] . '\library\data\Dbec.php'; echo "path: $path"; die();` See just see if your pathing is correct. If you don't get an echo then there is an error before this. – Pitchinnate May 29 '12 at 19:45
  • Yes I am getting the echo, if I place it just before the require_once. – Nick May 29 '12 at 19:58

3 Answers3

1

Check your error log, to see if anything is visibly wrong. Also try setting error_reporting = E_ALL, and make sure display_errors = On and log_errors = On in your php.ini.

Your file your trying to include is in '/library/membership/theScript.php', try doing:

require_once '../data/Dbec.php';
David
  • 2,365
  • 8
  • 34
  • 59
  • **Fatal error: require_once() [function.require]: Failed opening required '/home2/myaccount/public_html/mywebsite/library/membership/library/data/Dbec.php' (include_path='.:/usr/lib64/php:/usr/lib/php')** Does the include_path make any sense? – Nick May 29 '12 at 20:19
  • Include path does not matter here. If that require above did not work, go back one more level: `require_once '../../data/Dbec.php';` – David May 29 '12 at 21:10
0

This isn't going to do what you want. Everything after require_once is being interpreted as a conditional. It's running ($_SERVER['DOCUMENT_ROOT'] . '\library\data\Dbec.php') or die("could not load file") and returning 1, then running require_once 1.

To make it work as you expect, you would need an extra set of parentheses:

(require_once($_SERVER['DOCUMENT_ROOT'] . '\library\data\Dbec.php')) or die("could not load file");

Although, I'm not certain the die() will ever get called. It's up to you to figure out.

See this related bug report which was ruled "not a bug."

animuson
  • 53,861
  • 28
  • 137
  • 147
  • thanks... well I did not have much trust that the `die()` is going to ever be executed. The main issue remains that the script stops. – Nick May 29 '12 at 20:02
  • Have you tried enabling error reporting to see what the actual error is that you're getting? A blank white page is a classic sign of a hidden fatal error. – animuson May 29 '12 at 20:03
  • Thanks, I now did enable them. – Nick May 29 '12 at 20:20
0

Also problem can be in file permissions and filename. Windows filesystem is caseinsesetive but linux is not. So you have to check the filename and the fact that user who executes this script has read persmission on the file you try to include with require_once

lexabug
  • 191
  • 1
  • 3