【发布时间】:2012-10-27 22:45:22
【问题描述】:
基本上,我无法使用 php 网页连接到 mysql 数据库。 我使用向导在 C-panel 中创建了数据库 我是这样连接的
$db_host = "localhost"; //your host Database address
$db_username = "xxxx"; //your account username
$db_pass = "xxxxx"; //your account password
$db_name = "xxxxx"; //your database name
@mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
@mysql_select_db("$db_name") or die ("no database");
但我的页面似乎只是触发“无法连接到 mysql” 我的页面现在确实安装了 wordpress,但我打算在我自己创建网站时摆脱它。我只是对为什么无法连接感到困惑,因为在 Phpmyadmin(C 面板上的一项功能)中,它说数据库在 localhost 中。
【问题讨论】:
-
您确定用户名和密码正确吗?此外,您应该输出错误 (
mysql_error()) 以查看发生了什么问题。 -
"无法连接到 'Localhost' (10061) 上的 MySQL 服务器"