Jump to content

Require() Failed to open...


intregrisist

Recommended Posts

Hi, this may be verry easy to fix but I just can't find a solution.  I've been reading and following a book on PHP and Mysql and I just can't get my php file to run my other php file with the require() function.  This is my code:

 

<?php
require($_SERVER['DOCUMENT_ROOT'] . "/config/config.php");
$connection = mysql_connect($db_host, $db_user, $db_password) or die("error on connect");
echo "connection made";
         ?>

 

Thats all it is...

My config.php file is one folder up called config. 

 

ex.  document_root/config/config.php

      document_root/index.php  <---very simple yet can't find it  ???

 

I get the following:

Warning: require(/home/content/.../html/config/config.php) [function.require]: failed to open stream: No such file or directory in /home/content/..../html/temp_folder/index.php on line 2

Fatal error: require() [function.require]: Failed opening required '/home/content/.../html/config/config.php' (include_path='.:/usr/local/php5/lib/php') in /home/content/.../html/temp_folder/index.php on line 2

 

 

Please help...

Link to comment
https://forums.phpfreaks.com/topic/100871-require-failed-to-open/
Share on other sites

I GOT IT WORKING YEY  ;D

Thanks to BlueSkyIS!!  It was killing me to not get this connection going.  I am so happy thank you. For anyone who has the same problem here is the code:

 

	require($_SERVER["DOCUMENT_ROOT"] . "/temp_folder/config/config.php");
$connection = @mysql_connect($db_host, $db_user, $db_password) or die("error on connect");
echo "connection made";

 

The error was that $_SERVER["DOCUMENT_ROOT"]  was one folder behind in my way of thinking about it.  I had to include the folder my index.php file was on: "/temp_folder/config/config.php"

 

The book explained it differently.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.