William-B
asked on
require_once Path Error in PHP and Apache
I'm developing a moderately sized website using Dreamweaver CS4 and I've run into a problem with PHP and Apache. I'm using the most current release versions of each program and I've divided my site into folders primarily for organization. The problem is that if I have any php files that include php files that include other php files if the base php files are located in a sub directory the includes usually work but in the site root Apache complains in the error log that the files being included in the first included file cannot be found. I've included the relevant PHP files but cut out all the html and php functions to keep them reasonably sized. The default.php is the default page that opens up when the site is typed in, rotator.php is a php file that include functions for a banner ad type system, and the connBDBannerAds.php is the automatically generated MySQL connection file by Dreamweaver. Dreamweaver is just fine with all the links but Apache outputs this when it runs:
[Fri May 22 22:42:10 2009] [error] [client 127.0.0.1] PHP Warning: require_once(../Connection s/connBDBa nnerAds.ph p) [<a href='function.require-onc e'>functio n.require- once</a>]: failed to open stream: No such file or directory in C:\\Program Files (x86)\\Apache Software Foundation\\Apache2.2\\htd ocs\\web test\\PHP\\rotator.php on line 1
[Fri May 22 22:42:10 2009] [error] [client 127.0.0.1] PHP Fatal error: require_once() [<a href='function.require'>fu nction.req uire</a>]: Failed opening required '../Connections/connBDBann erAds.php' (include_path='.;C:\\Progr am Files (x86)\\Apache Software Foundation\\Apache2.2\\htd ocs\\web test') in C:\\Program Files (x86)\\Apache Software Foundation\\Apache2.2\\htd ocs\\web test\\PHP\\rotator.php on line 1
I'm using relative links right now but I've also tried site root ones as well where Dreamweaver changes all the require_once lines with virtual. I also tried prefixing all the paths with / to make it use the site root but that didn't work either.
This is my first post so if I forgot to put something in or put too much in please let me know. Thanks in advance for your time.
[Fri May 22 22:42:10 2009] [error] [client 127.0.0.1] PHP Warning: require_once(../Connection
[Fri May 22 22:42:10 2009] [error] [client 127.0.0.1] PHP Fatal error: require_once() [<a href='function.require'>fu
I'm using relative links right now but I've also tried site root ones as well where Dreamweaver changes all the require_once lines with virtual. I also tried prefixing all the paths with / to make it use the site root but that didn't work either.
This is my first post so if I forgot to put something in or put too much in please let me know. Thanks in advance for your time.
default.php
<?php require_once('Connections/connBDCustomers.php'); ?>
<?php require_once('PHP/rotator.php'); ?>
<?php
if (!function_exists("GetSQLValueString"))
{
.... Other php stuff ....
}
?>
HTML Body
--------------------------------------------------------------------------------
rotator.php
<?php require_once('../Connections/connBDBannerAds.php'); ?> <-Problem Here I think
<?php
function rotator()
{
}
?>
----------------------------------------------------------------------------------
connBDBannerAds.php
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connBDBannerAds = "localhost";
$database_connBDBannerAds = "bdbannerads";
$username_connBDBannerAds = "root";
$password_connBDBannerAds = "test";
$connBDBannerAds = mysql_pconnect($hostname_connBDBannerAds, $username_connBDBannerAds, $password_connBDBannerAds) or trigger_error(mysql_error(),E_USER_ERROR);
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for your prompt solution. It worked great.
ASKER