With school we are learning about Database connections. We are working with W10 and XAMPP, but the problem we come along every time is this throw error:
include(): Failed opening 'db_connection.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\practice\index.php on line 2
We used multiple sources, namely a video from Dani Krossing regarding Database connections with PDO (https://www.youtube.com/watch?v=BaEm2Qv14oU) and a source from the PHP website itself, which is the same that Dani used in his video. The code is the following:
private function connect() {
try {
$username = "root";
$password = "";
$dbh = new PDO('mysql:host=localhost;dbname=ooplogin', $username, $password);
return $dbh;
}
catch (PDOException $e){
print "Error! " . $e->getMessage() . "<br/>";
die();
}
}
My question is where the fault is, because the most of us are getting the same error like me.
I tried to do some research, and found this, but I'm not really sure if that'll fix the problem for us.
Please leave some alternative suggestions or solutions, or ask for more info if you aren't coming out with all these sources.
Thanks in advance!