Warning: mysqli_connect(): (28000/1045): Access de

2019-03-06 18:43发布

问题:

This question already has an answer here:

  • MySQLI 28000/1045 Access denied for user 'root'@'localhost' 2 answers

i uploaded my php config code to my server befirstw on cpanel ...under the public html .. my php file is

<?php

$dbhost = "befirstwin.com";
$dbname = "befirstw_intlgent";
$dbuser = "befirstw_intelli";
$dbpass = "Ngcp1988$ ";


$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);

if(mysqli_connect_errno())
{
die("database connection failed: " .
mysql_connect_error() . "("  . mysql_connect_errno() .")"
);
}
$username = isset($_GET['username']) ? $_GET['username'] : '';
$password = isset($_GET['password']) ? $_GET['password'] : '';

$query = "INSERT INTO users 
           VALUES ('', '$username', '$password')";

$result = mysqli_query($connection,$query);

if(!$result)
{
die("we have problem");
}

mysqli_close($connection);
?>

i am getting this error Warning: mysqli_connect(): (28000/1045): Access denied for user 'befirstw_intelli'@'s147.adk-media.com' (using password: YES) in /home/befirstw/public_html/connectimagedb.php on line 8

if you have any idea or any thing more required for php connectivity plz suggest

回答1:

I check that $ sign in the password is creating problem in my case.Please Do not use $ or any other special Character that may create problem. In my case $ sign in password was creating problem



回答2:

This could simply be caused by an incorrect password. In your $dbpass, is the space at the end supposed to be there? That extra space before the close " would add a space to the end of the password, causing it to be a different password.



回答3:

I am wondering if you are opening a connection. I notice the line, where it is closing a connection but not sure if you have opened a connection? Where is is your execute statement for the Insert Query?

Thanks