I have the PHP code for my Database and I am trying to allow it to connect and it keeps throwing back and error saying unable to log in. I know that the code correct but it looks like the database is preventing it from connecting to it. Does anyone know what correct Info and setting is to allow the connection?
Here is my code for reference. Password and Database has been removed for Protection reasons.
<?php
$con = new mysqli("localhost", "User", "XYZPassword", 'Databasename');
if ($con->connect_error) {
die("Connection failed: " . $con->connect_error);}
$sql = "USE Databasename; SELECT * FROM `TABLEName`";
$query = $con->query($sql);
if ($query->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "username: " . $row["username"];
}
} else {
echo "0 results";
}