2013-08-07 167 views
1

我想連接到服務器上託管的MySQL。使用的面板是cpanel。但我無法連接到數據庫。使用xamp在本地系統上運行php代碼。 錯誤在下面。當數據在服務器上(cPanel)連接到本地主機的mysql

Warning: mysql_connect(): 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 C:\xampp\htdocs\index.php on line 2 

Warning: mysql_query() expects parameter 2 to be resource, string given in C:\xampp\htdocs\index.php on line 5 

Warning: mysql_error() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\index.php on line 5 

即使我已經把%作爲通配符條目來允許所有主機但沒有運氣。任何想法有什麼不對。

回答

1

嘗試使用帶有域名的端口號mysql_connect();。默認的mysql端口號是3306

mysql_connect('yourdomain.com:3306', 'user', 'password'); 
相關問題