gpt4 book ai didi

php - mysqli_connect() : (28000/1045): Access denied for user 'username' @'localhost' (using password: YES)

转载 作者:行者123 更新时间:2023-12-05 08:23:29 25 4
gpt4 key购买 nike

当我在共享主机服务器中配置数据库时出现此错误

mysqli_connect(): (28000/1045): Access denied for user 'username'@'localhost' (using password: YES)

但它在本地主机上正常工作。

<?php 
session_start();



if($_SERVER['HTTP_HOST']=="localhost")
{
$serverIp="localhost";
$userName="user1";
$password="XXXXX";
$dbname="example";

}else
{


$serverIp="localhost";
$userName="username";
$password="password";
$dbname="dbname";
}

$cn=mysqli_connect($serverIp,$userName,$password) OR Die("Couldn't Connect - ".mysql_error());
$link=mysql_select_db($dbname,$cn)or Die("Couldn't SELCECT - ".mysql_error());
?>

最佳答案

只需更改您的 cpanel 密码即可。

关于php - mysqli_connect() : (28000/1045): Access denied for user 'username' @'localhost' (using password: YES),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42877269/

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