Why does this getMessages product fatal error?
Posted: Wed Jan 06, 2016 10:21 am
When I use this, I get Fatal Error messages. I really don't know why. It could be the server's error setup, to catch tiny things.
[text][Wed Jan 06 16:04:54 2016] [warn] [client 79.**.120.150] mod_fcgid: stderr: PHP Fatal error: Call to undefined method PDOException::getMessages() in /home/plat-linnas01/s/sandbox.website.co.uk/user/htdocs/dbconn.php on line 20[/text]
[text][Wed Jan 06 16:04:54 2016] [warn] [client 79.**.120.150] mod_fcgid: stderr: PHP Fatal error: Call to undefined method PDOException::getMessages() in /home/plat-linnas01/s/sandbox.website.co.uk/user/htdocs/dbconn.php on line 20[/text]
Code: Select all
<?php
if (!defined('DBUSER')) {
define('DBHOST', '***ip here ***');
define('DBUSER', 'username');
define('DBPASS', 'password');
define('DBNAME', 'databasename');
}
$sqlconn = mysql_connect(DBHOST, DBUSER, DBPASS);
if ($sqlconn) {
mysql_select_db(DBNAME);
}
try {
$pdo = new PDO('mysql:host=' . DBHOST . ';dbname=' . DBNAME, DBUSER, DBPASS);
} catch (Exception $e) {
$to = "emailaddress";
$subject = "DB Down";
$headers = "From: info@website.co.uk";
$body = "DB Error: " . $e->getMessages();
mail ($to, $subject, $body, $headers);
}
?>