-1
最近我切换到的cPanel,并从那时起,我有问题。我遇到连接到数据库的问题。我在CPanel中创建了它,假设用户名为'root'
,密码为'123'
。我有一个文件/scripts/dbh.php
和一个文件/index.php
。这里是内容。的cPanel数据库连接错误
dbh.php:
<?php
// Database Handler
$db_name = 'hughchalmers';
$servername = "localhost";
$username = "root";
$password = "123";
$table_name = 'accounts';
$conn = mysqli_connect($servername, $username, $password, $db_name) or die('Cannot connect to database. Contact an admin');
?>
(hughchalmers是一个数据库,账户是一个表)
的index.php:
<?php
include($_SERVER['DOCUMENT_ROOT'].'/memedictionary/scripts/header.php');
include($_SERVER['DOCUMENT_ROOT']. '/memedictionary/scripts/dbh.php')
?>
<head>
<title>Login</title>
</head>
<body>
</body>
有什么问题吗?它只是随着我设置的消息而死亡(无法连接到数据库,请联系管理员)。道歉,我很新的MySQL和的cPanel
第四个参数是数据库,不是表。是'accounts'一个数据库或表? – chris85
accounts是数据库中的一个表。编辑的问题,仍然不起作用。 –
使用连接错误功能获取更多信息。 http://php.net/manual/en/mysqli.connect-error.php – chris85