Page 1 of 1

PHP includes unable to find file.

PostPosted: 09. August 2004 20:02
by wastvedt
Hi!
I'm using xampp on windows XP, and am writing a page for a form that includes a database connection script:

Code: Select all
require_once ('../mysql_connect.php') or die ('Could not connect to the database: ' . mysql_error() );


When I ran the page the form displayed, but I got this error at the place in the form where the include was called:

Warning: main(../mysql_connect.php): failed to open stream: No such file or directory in C:\TrygLand\Utilities\xampp\htdocs\websites\bandsite\submit_photos.phpon line 47

Fatal error: main(): Failed opening required '../mysql_connect.php' (include_path='.;C:\TrygLand\Utilities\xampp\php\pear\') in C:\TrygLand\Utilities\xampp\htdocs\websites\bandsite\submit_photos.phpon line 47


Just a few minutes ago I was messing around with file locations and syntax to try to get the page to work properly, and when I deleted the 'or die' part of the require_once, the page worked fine. I have no clue why that worked, and would like to be able to use error reporting in future sites, so any help anyone could provide would be great.

Thanks again,
wastvedt :D

PostPosted: 09. August 2004 20:39
by Wiedmann
@(require_once('../mysql_connect.php')) or die('Could not read required file \'../mysql_connect.php\'!');

inside mysql_connect.php:
$link = mysql_connect($host, $user, $pass) or die('Could not connect to the database: '.mysql_error());

Thanks

PostPosted: 11. August 2004 01:31
by wastvedt
Thanks for the quick reply! That worked perfectly.
wastvedt :D