There's a site I'm developing, and I don't really understand the problem that is occurring...
There's a link inside a table in the Home page. When I click on it, It is supposed to provide some GET parameters to the hyperlinked page. The receiving page processes it, updates the database and redirects to the Home Page.
I've included some necessary php files as "require_once()
" in the Home page. But I can't do it on the processing page. It gives some warnings. I don't really understand why and I don't know the solution to this problem. Please help!
Code in the Home page:
<?php require_once("includes/db_connection_open.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php include("includes/header_main.php"); ?>
<?php
echo "<td><a href='includes/process.php?id=".$arr['id']."'>Process</a></td>";
?>
<?php include("includes/body_footer_main.php"); ?>
<?php require_once("includes/db_connection_close.php"); ?>
Code in the Processing Page:
<?php require_once("includes/db_connection_open.php"); ?>
<?php require_once("includes/functions.php"); ?>
//Processing codes
<?php require_once("includes/db_connection_close.php"); ?>
The warnings I'm getting are:
Warning: require_once(includes/db_connection_open.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\MySite\includes\process.php on line 1
Fatal error: require_once() [function.require]: Failed opening required 'includes/db_connection_open.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\MySite\includes\process.php on line 1
It seems like you are currently in the includes
directory because your error says 'in C:\xampp\htdocs\MySite\includes\process.php on line 1'.
However you are still trying to require within includes/
so you end up in includes/includes/
where your files aren't at.
If you are having troubles finding the correct path because you have a file that is loaded through inclusion as well as AJAX for example you can use __DIR__
(or dirname(__FILE__)
in older PHP installations) to make sure you have the correct path.
So in process.php
that would be for example:
require_once __DIR__.'/db_connection_open.php';