Hi I am having a problem with my index.php whenever I go to http://localhost/blog/admin/index.php I get an error: Fatal error: Call to undefined function Blog\DB\connect() in C:\xampp\htdocs\blog\blog.php on line 6. In admin folder I am requiring my blog.php.
index.php
<?php
require '../blog.php';
?>
Now in blog.php
<?php
require 'functions.php';
require 'db.php';
$conn = Blog\DB\connect($config);
if( !$conn )
{
die('couldnt connect to the database');
}
Now In db.php
<?php namespace Blog\DB;
require 'config.php';
function connect($config)
{
try{
$conn = new \PDO('mysql:host=localhost;dbname=blogs',
$config['DB_USERNAME'],
$config['DB_PASSWRORD']);
$conn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
return $conn;
}
catch(PDOException $e)
{
return false;
}
}