First, take a look at my code


    $dbh = new PDO('mysql:host=$db_host;dbname=blogproject1','root','');
    $dbh->exec('SET NAMES "utf8"');
catch (PDOException $e)
    die('Error: ' . $e->getMessage());

if(!defined('GUEST')) {
    define('BASEPATH', dirname(dirname(__FILE__));
    header('Location: ' . BASEPATH);

When it executed it gives me an error.. Looks like, the error is at the header function... Can you tell me how to fix it?

What is the exact error?

Most likely, the connection failed, echoed an error, causing the header not to function. I think it should be:

SET NAMES 'utf8'

Single quotes, not double.

You can use it in connection string like

$dbh = new PDO('mysql:host=$db_host;dbname=blogproject1;charset=utf8','root','');

instead of

$dbh->exec('SET NAMES "utf8"');

OR else you can use the same but you are having a syntax error

$dbh->exec('SET NAMES "utf8"');

should be

$dbh->exec("set names utf8");