4

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);
Edward Maya
  • 429
  • 2
  • 10
  • 25
  • It looks as if your script cannot connec to the mysql server. Did you check the mysql web site to see what those error codes mean? – vascowhite Mar 13 '12 at 11:02

3 Answers3

8

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.

Fawad Ghafoor
  • 6,039
  • 7
  • 41
  • 53
3

for the hostname/host try to use your credentials found in the Zend Server -> PHP Cloud tab -> Overview page -> User Parameters tab... then make the "host" part in the credentials like this:

[general]
 db.adapter = PDO_MYSQL
 db.params.host = CONTAINERNAME-db.my.phpcloud.com
 db.params.username = ZEND_DB_USERNAME
 db.params.password = ZEND_DB_USERNAME
 db.params.dbname = ZEND_DB_DBNAME
Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
  • hi Marek Sebara, what changes did you add to my answer? I cannot identify them other than the "newline" characters. It says "24 characters are added", but I dont see them – Frederick G. Sandalo Feb 13 '14 at 03:19
0

Did you check your mysql database is up?

If you are sure it is, check that your adapters configuration is ok, maybe the host parameter is not properly configured.

arraintxo
  • 484
  • 2
  • 12
  • how to know that mysql is up ?? both apache and my sql are running.i am editing my question so that u see some more code – Edward Maya Mar 13 '12 at 11:47
  • try connecting to mysql through command line "mysql.exe -uroot -p -h 192.168.0.233" or you can try with "telnet 192.168.0.233 3306" if you don't have mysql installed on your host. – arraintxo Mar 13 '12 at 11:59