I don’t know about PHP scripts. Am a iPhone developer. I want to enable Apple Push Notification for my iPhone app. Am following tutorial http://www.raywenderlich.com/3525/apple-push-notification-services-tutorial-part-2. Am getting this following error in my push_development.log file while run the push.php file from Terminal,
Terminal command:
unknownc42c032e8297:~ creagx$ cd /Users/creagx/Desktop/PushChatServer
unknownc42c032e8297:PushChatServer creagx$ php push/push.php development
Error message in push_development.log file:
2012-05-14T10:17:14+05:30 Push script started (development mode)
2012-05-14T10:17:14+05:30 Exiting with fatal error: exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /Users/gopi/Desktop/PushChatServer/push/push.php:82
Stack trace:
#0 /Users/gopi/Desktop/PushChatServer/push/push.php(82): PDO->__construct('mysql:host=loca...', 'gopipush', 'uH4q9xQGNAuFW...', Array)
#1 /Users/gopi/Desktop/PushChatServer/push/push.php(36): APNS_Push->__construct(Array)
#2 {main}
I want to know what are the values passing through this command?
// Create a connection to the database.
$this->pdo = new PDO(
'mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['dbname'],
$config['db']['username'],
$config['db']['password'],
array());
writeToLog('PDO Value: ' . $this->pdo);
I tried to print the PDO values in log file using writeToLog('PDO Value: ' . $this->pdo);. Can anyone please tell me how to know the pdo values? Thanks in advance.
EDIT:
// Create a connection to the database.
$this->pdo = new PDO(
'mysql:host=' . $config['db']['host'] . ';dbname=' . $config['db']['dbname'],
$config['db']['username'],
$config['db']['password'],
array());
writeToLog('Host: ' . $config['db']['host']);
writeToLog('DataBase: ' . $config['db']['dbname']);
writeToLog('Username: ' . $config['db']['username']);
writeToLog('Password: ' . $config['db']['password']);
Again got the same error message in log file. I think the writeToLog('Host: ' . $config['db'][‘host’]); line won’t compile until the error fix in $this->pdo line. Is it correct? Please help me. Thanks in advance.
PDO is a class… you can use var_dump to inspect it’s member variables. var_dump outputs directly, so you can catch it with output buffering as follows:
To be honest, it’s probably just as easy to do:
This is all assuming that
writeToLogis a working function you’ve created. If not, justechoinstead.