I'm getting Access denied for user 'user11'@'localhost' (using password: YES)
error using the code below:
My config.ini file: (stored in /home1/user
)
[database]
username=user11
password=my_password_here
dbname=my_database_name_here
My PHP file: (Stored in the home1/user/public_html
folder)
<?php
error_reporting(0);
$input = $_GET['data'];
$config = parse_ini_file('../config.ini');
$conn = new mysqli('localhost', $config['username'], $config['password'], $config['dbname']);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT student FROM studentslist WHERE award='$input'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo $row["student"];
}
} else {
echo "0 results";
}
$conn->close();
?>
My user name, password and database name are all correct. I've already assigned full privilege to the user11
from cPanel. Any help is appreciated.
source https://stackoverflow.com/questions/67942003/access-denied-for-user-user11localhost-using-password-yes
No comments:
Post a Comment