I am trying to connect to my database via PHP but get blank page when I run through Safari(http://pushchat.local:11111/test/databasename.php)
I can see my datbasename.php file under http://pushchat.local:11111/test/ as shown below:
Following is my PHP code:
try
{
if (!defined('APPLICATION_ENV'))
define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : ‘development’);
require_once '../api_config.php';
$config = $config[APPLICATION_ENV];
$pdo = new PDO(
'mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['dbname'],
$config['db']['username'],
$config['db']['password'],
array());
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->query('SET NAMES utf8');
echo 'Database connection successful!';
}
catch (Exception $e)
{
echo 'Could not connect to the database. Reason: ' . $e;
}
I even tried to put a stop sigh using codebug but I think it never stops.
Thanks for your help.