Just had the database.php file changed from from MySQL to PDO. But I'm getting this error:
Fatal error: Call to a member function query() on a non-object in /home/mypath/mydomain.com/library/database.php on line 19
It's working fine on the site of the individual who made the change. But when uploaded to my site it's generating this error, not sure why. I use DreamHost. What's wrong?
Line 19:
$result = $pdo->query($sql);
Code prior:
<?php
require_once 'config.php';
try {
$conn = new PDO("mysql:host=$servername;dbname=onlysecret_db", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
function dbQuery($sql)
{
global $pdo;
$result = $pdo->query($sql);
return $result;
}