Uncaught exception 'PDOException' with message 'invalid data source name' : <p>I know there are many question regarding on stackoverflow but i read them all but my didn't fixed, so i asked new question. I have a file named as article.php and i have the this code init. Just a code which is showing error.</p>

<pre><code>public static function getById( $id ) {
$conn = new PDO( DB_HOST, DB_USERNAME, DB_PASSWORD );
$sql = "SELECT *, UNIX_TIMESTAMP(publicationDate) AS publicationDate FROM articles WHERE id = :id";
$st = $conn-&gt;prepare( $sql );
$st-&gt;bindValue( ":id", $id, PDO::PARAM_INT );
$st-&gt;execute();
$row = $st-&gt;fetch();
$conn = null;
if ( $row ) return new Article( $row );
</code></pre>

<p>I am getting this error:</p>

<pre><code>Fatal error: Uncaught exception 'PDOException' with message 'invalid data source name' in C:\wamp64\www\classes\Article.php on line 102
( ! ) PDOException: invalid data source name in C:\wamp64\www\cms\classes\Article.php on line 102
</code></pre>

<p>My config file looks like</p>

<pre><code>ini_set( "display_errors", true );
define( "DB_HOST", "localhost" );
define( "DB_USERNAME", "username" );
define( "DB_PASSWORD", "" );
define('DB_NAME', 'name');
</code></pre>

<p>Can you tell me why this happens and where i am doing mistake. Thanks</p>
