What's new

Help Pahelp sa php error

choiniglory03

Honorary Poster
Established
Joined
Jun 1, 2018
Posts
157
Reaction
454
Points
203
Age
30
Warning: require_once(C:/xampp/htdocs\student-gradings\includes\config.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\studentgradings\includes\initialize.php on line 21

Fatal error
: Uncaught Error: Failed opening required 'C:/xampp/htdocs\student-gradings\includes\config.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\studentgradings\includes\initialize.php:21 Stack trace: #0 C:\xampp\htdocs\studentgradings\index.php(2): require_once() #1 {main} thrown in C:\xampp\htdocs\studentgradings\includes\initialize.php on line 21
ito codes ko

require_once(LIB_PATH.DS."config.php");

ito codes sa config.php

<?php
/**
  • Description: The main class for Database.
  • Author: Joken Villanueva
  • Date Created: october 27, 2013
  • Revised By:
*/

//Database Constants
defined('DB_SERVER') ? null : define("DB_SERVER","localhost");//define our database server
defined('DB_USER') ? null : define("DB_USER","root"); //define our database user
defined('DB_PASS') ? null : define("DB_PASS",""); //define our database Password
defined('DB_NAME') ? null : define("DB_NAME","dbgrading"); //define our database Name

$thisFile = str_replace('\\', '/', FILE);
$docRoot =$_SERVER['DOCUMENT_ROOT'];

$webRoot = str_replace(array($docRoot, 'includes/config.php'), '', $thisFile);
$srvRoot = str_replace('config/config.php','', $thisFile);

define('WEB_ROOT', $webRoot);
define('SRV_ROOT', $srvRoot);
?>
 
The error is occurring because the file config.php cannot be found. The path specified in the require_once statement is incorrect.

In the error message, it shows that the file is being searched for in the path C:/xampp/htdocs\student-gradings\includes\config.php. However, the correct path should be C:/xampp/htdocs/student-gradings/includes/config.php. Notice that the backslash \ is being used instead of the forward slash / in the path.

To fix the error, you need to update the path in the require_once statement in the initialize.php file. Replace the line:

PHP:
require_once(LIB_PATH.DS."config.php");

with:

PHP:
require_once(LIB_PATH . "/config.php");

This will ensure that the correct path is used to include the config.php file.

Additionally, there is an issue in the config.php file. The line:

PHP:
$thisFile = str_replace('\\', '/', FILE);

should be:

PHP:
$thisFile = str_replace('\\', '/', __FILE__);

The __FILE__ constant should be used instead of FILE.

After making these updates, the error should be resolved, and the config.php file should be successfully included.
 

Similar threads

Back
Top