Fatal error: require_once(): Failed opening required '.\DbConnect.php' (include_path='B:\xamp\php\pear') in B:\xamp\htdocs\Library\includes\DbOperations.php on line 12
<?php
include'B:\xamp\php\pear';
class DbOperations{
private $con;
function __construct(){
require_once dirname(_FILE_).'/DbConnect.php'; -->Error
$db = new DbConnect();
$this->con = $db->connect();
}
/*CRUD -> C -> CREATE*/
/*********************STUDENT TABLE******************************/
function createstudent($username,$password,$email){
$password = md5($pass);
$stmt = $this->con->prepare("INSERT INTO `tbl_student` (`id`, `username`, `email`, `password`, `CourseName`, `Semester`, `RegDate`, `updationDate`) VALUES (NULL, '?', '?', '?', '?', '?', current_timestamp(), NULL);");
$stmt->bind_param("sss",$username,$password,$email);
/*$stmt->bind_param(':username',$username,PDO::PARAM_STR);
$stmt->bind_param(':password',$password,PDO::PARAM_STR);
$stmt->bind_param(':email',$email,PDO::PARAM_STR);*/
if($stmt->excute()){
return true;
}
else {
return false;
}
}
?>
I have specified the right path for the pear , but still, the same error is popping up not sure what's wrong.
This is DbConnect.php
<?php
//include('B:\xamp\php\pear');
class DbConnect{
private $con;
function __construct(){
}
function connect(){
include_once dirname(_FILE_).'/Constants.php';
$this->con = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
if(mysqli_connect_errno()){
echo "Failed to connect with Database".mysqli_connect_err();
}
return $this->con;
}
}
?>
Error messages
Warning: include(B:\xamp\php\pear): failed to open stream: Permission denied in B:\xamp\htdocs\Library\admin\includes\DbOperation.php on line 3
Warning: include(): Failed opening 'B:\xamp\php\pear' for inclusion (include_path='B:\xamp\php\pear') in B:\xamp\htdocs\Library\admin\includes\DbOperation.php on line 3
Warning: include(B:\xamp\php\pear): failed to open stream: Permission denied in B:\xamp\htdocs\Library\includes\DbOperations.php on line 3
Warning: include(): Failed opening 'B:\xamp\php\pear' for inclusion (include_path='B:\xamp\php\pear') in B:\xamp\htdocs\Library\includes\DbOperations.php on line 3
Warning: Use of undefined constant FILE - assumed 'FILE' (this will throw an Error in a future version of PHP) in B:\xamp\htdocs\Library\includes\DbOperations.php on line 12
Warning: require_once(.\DbConnect.php): failed to open stream: No such file or directory in B:\xamp\htdocs\Library\includes\DbOperations.php on line 12
Fatal error: require_once(): Failed opening required '.\DbConnect.php' (include_path='B:\xamp\php\pear') in B:\xamp\htdocs\Library\includes\DbOperations.php on line 12