Saturday, 5 November 2016

I am trying to connect to mysql database with php code but it gives me this errors (see below)

I am trying to connect to mysql database with php code but it gives me this error: Warning: mysqli_connect(): (HY000/1044): Access denied for user ''@'localhost' to database 'test1' in C:\xampp\htdocs\imobiliare\server.php on line 8


Warning: mysqli_query() expects parameter 1 to be mysqli, bool given in C:\xampp\htdocs\imobiliare\server.php on line 11


Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\imobiliare\server.php on line 13


$servername = "localhost";
$username = "";
$password = "";
$dbname = "test1";
$conn = mysqli_connect($servername, $username, $password, $dbname);
$sql = "SELECT id, camere, zona, pret FROM apartamente";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo "id: " . $row["id"]. "Camere: " . $row["camere"]. "Zona:" . $row["zona"]. "Pret: " . $row["pret"]."
";
}
}
?>

I would like to echo the results

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...