<?php $dbhost = ''; $dbname = ''; $dbuser = ''; $dbpass = ''; try { $db = new PDO('mysql:host='.$dbhost.';dbname='.$dbname.'', $dbuser, $dbpass); } catch(PDOException $e) { echo 'Error: ' . $e->getMessage(); } $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $db->query("SET NAMES 'utf8'"); ?>