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

S C

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

<?php

$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"]."<br>";
 }
 }

  ?>

I would like to echo the results

Atmanirbhar Bharat

You need to grant the access to the database test1 by running the command on the MySQL prompt

mysql> GRANT ALL PRIVILEGES ON test1.* TO 'username'@'localhost';

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I'm trying to connect to mysql database with php, but it gives me an error

I am trying to make a discord bot in java script on repl.it but it gives me an error error above code below

i am trying to create foreign keys but i got error 1822 .. please see my code below

I am trying to import csv file into mysql, but I am getting below error. Can anyone help me?

I am trying to install the drivers and the kernel gives me this error:

I am trying create a button in which boolean function should be performed. below is my view code. Can anyone help me

I am trying to use amazon api code in php but it is giving me error of not supported version following is my code

i am trying to read a text file in visual basics but i am not able to store the details in the array it gives errors

PHP not running when trying to connect to MySQL database

Error trying to connect to MySQL database in PHP

errors in visual studio webpage code (Trying to connect the website to a database)

submit button is not working. i have a mysql database and i am trying to make a php form

When I am trying to push code on Git it shows errors

what i am missing to connect my C# code to MySQL database

I am trying to create a text box which allows only numbers using typescripts. See below example

How to write the data into json file for the following code below and i am getting the following errors any one help me whats wrong in my code

I am trying to implement CDC on MySQL database using AWS DMS. Getting following errors in my dms migration task :

trying to connect to mysql database

trying to connect database with php

Is the mysql connector needed when I am trying to connect using JPA?

i am trying to retrieve the data from fire base database using recycler view but i am getting errors in it

I am trying to connect my web page to my local server database but I am getting error ECONNREFUSED

I am new to using mysql - as i was trying to create a table i got the error below

I am trying to analyze below query related to hierarchical and Regex can any one help me in understanding?

I am trying to delete a record in the database using mysql javascript API

I am trying to store the values of a complex checkbox form in mysql database

I am trying to clear typeorm mysql database on server shutdown (NestJS)

Should I rely on MySQL errors in PHP code?

I am trying to wrap my head around below elasticsearch dsl. Can someone tell me how `must` clause is used below