'PDOException' with message 'SQLSTATE[HY000] [2002] zend framework

Edward Maya picture Edward Maya · Mar 13, 2012 · Viewed 50.7k times · Source

Any one plz tell me why i am getting this error ?? firstly my internet connection was good today its not good so i am getting this error.how can i fix this any idea plz??

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] A 
connection attempt failed because the connected party did not properly respond after a 

period of time, or established connection failed because connected host has failed to
respond. ' in D:\SVN 
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Pdo\Abstract.php:129 

Stack trace: #0 D:\SVN     
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Pdo\Abstract.php(129):  
PDO->__construct('mysql:host=192....', 'root', 'root', Array) #1 D:\SVN   
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Pdo\Mysql.php(109): 
Zend_Db_Adapter_Pdo_Abstract->_connect() #2 D:\SVN  
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Abstract.php(860):  
Zend_Db_Adapter_Pdo_Mysql->_connect() #3 D:\SVN  
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Abstract.php(930):  
Zend_Db_Adapter_Abstract->quote('testing', NULL) #4 D:\SVN 
data\WebClient_PHP\trunk\p\library\Zend\Auth\Adapter\DbTable.php(449): Zen 
in D:\SVN 
data\WebClient_PHP\trunk\p\library\Zend\Db\Adapter\Pdo\Abstract.php on line 
144

this is my config.ini

[general]
db.adapter = PDO_MYSQL
db.params.host = 192.168.0.233
db.params.username = root
db.params.password = my_password
db.params.dbname = "mydatabasename"

some code from my index.php

$config = new Zend_Config_Ini(ROOT_DIR.'/application/config.ini', 'general');
$DB = Zend_Db::factory($config->db);
Zend_Db_Table::setDefaultAdapter($DB);

Answer

Fawad Ghafoor picture Fawad Ghafoor · Mar 14, 2012

it seems that your code this portion is not working

[general]
 db.adapter = PDO_MYSQL
 db.params.host = 192.168.0.233
 db.params.username = root
 db.params.password = my_password
 db.params.dbname = "mydatabasename"

either the IP is not correct if so go to cmd in windows and type ipconfig you will get your correct ip paste it here OR just simply write

 db.params.host = localhost

if and only if you are using locally may be it works.