Question

I just finished working on a site. Everything is working fine on the local server but the page won't open if I use index.php on a live server. index.html does work on the live server but all the PHP code enclosed in <?php ?> are displayed as-is instead of running.

My site is hosted at Linux Hosting with cPanel and I have uploaded my files via FileZilla to the web root (public_html/www) folder.

Connection to the database is

<?php 
   require_once('Conn\connection.php');
?>

 HTML and embeded PHP goes here...

This works fine on WAMP.

Was it helpful?

Solution

Aha! Try this instead:

require_once 'Conn/connection.php';

The backslash is invalid on Linux systems, but will work fine on Windows. Switching to the forward slash should work on both. My guess is that your program is exiting early with a fatal error, and if you check your web server logs, you'll see the problem.

Also, since require_once is a keyword, I tend to use it without brackets, even though brackets will work. There are circumstances in which calling it in a function context is necessary, but this isn't one of them.

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