Document_root include showing blank page on localhost site

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Document_root include showing blank page on localhost site

Postby Jimjim » 20. April 2016 18:31

Hey I hope you can help

I am using $_SERVER['DOCUMENT_ROOT']. for my PHP include

I recently started to use XAMP control panel v3.2.2, I may of missed a configuration setting somewhere but I'll try my best to explain the problem

My website index.php is located in the directory /website/ and I am including a file from a directory on the same level such as /example/

The include looks like this:
Code: Select all
include($_SERVER['DOCUMENT_ROOT'].'/example/config.php');

My PHP include works fine on the live server on my web-host, but when I try viewing the same site/page on my localhost machine I get a blank page, no errors in the error log, so I assume that I have the include set up correctly but the content isn't showing

I have setup an entry in httpd-vhosts.conf that looks like this:
Code: Select all
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/my_site"
ServerName test.dev
ServerAlias www.test.dev
<Directory "C:/xampp/htdocs/my_site">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

And I have also changed my hosts file with these 2 entries:
Code: Select all
127.0.0.1       www.test.dev
127.0.0.1       test.dev

If the files are being included from within a sub-directory, all works fine if I use this:
Code: Select all
include("folder_name/config.php");

But I want to keep my current file-structure

Thanks!
Jimjim
 
Posts: 2
Joined: 20. April 2016 17:11
XAMPP version: v3.2.2
Operating System: Win 7

Re: Document_root include showing blank page on localhost si

Postby Jimjim » 02. May 2016 16:25

thanks for the help :?
Jimjim
 
Posts: 2
Joined: 20. April 2016 17:11
XAMPP version: v3.2.2
Operating System: Win 7

Re: Document_root include showing blank page on localhost si

Postby Altrea » 02. May 2016 17:13

Hi,

Did you try to print out $_SERVER['DOCUMENT_ROOT'].'/example/config.php to see whats in there?

Best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 52 guests