gpt4 book ai didi

php - 如何访问 cpanel 服务器中的数据库?

转载 作者:行者123 更新时间:2023-11-29 11:03:03 25 4
gpt4 key购买 nike

我的网站出现以下错误:

Warning: mysql_connect(): Access denied for user 'mydb_db'@'localhost' (using password: YES) in /home/fiveghr/public_html/don/dbconnection/connection.php on line 8 Could not connect: Access denied for user 'mydb_db'@'localhost' (using password: YES)

<?php
$rpath = $_SERVER["DOCUMENT_ROOT"];
require $rpath."/don/dbconnection/config.php";
class getdbconnection {
public function getConnection(){
// $con = mysql_connect("localhost","*****","******");
$con = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if (!$con)
{
return die('Could not connect: ' . mysql_error());
} else {
// mysql_select_db("real_state", $con);
mysql_select_db(DB_NAME, $con);
//return $con;
}
}
}
?>

最佳答案

DB_HOST 的值服务器地址必须为 "http://www.myserver.com" 而不是 localhost

关于php - 如何访问 cpanel 服务器中的数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41890662/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com