Warning: mysqli_connect(): (HY000/1044): Access denied for user ''@'localhost' to database 'drasticdata' in C:\xampp\htdocs\Gis\koneksi.php on line 9 Koneksi gagal: Access denied for user ''@'localhost' to database 'drasticdata'


#1

Anyone can u help me to fix this problem
Warning: mysqli_connect(): (HY000/1044): Access denied for user ‘’@‘localhost’ to database ‘drasticdata’ in C:\xampp\htdocs\Gis\koneksi.php on line 9 Koneksi gagal: Access denied for user ‘’@‘localhost’ to database ‘drasticdata’

this is my source for connection

<?php $servername = "localhost"; $database = "drasticdata"; $username = ""; $password = ""; $conn = mysqli_connect($servername, $username, $password, $database); if (!$conn) { die("connection failed: " . mysqli_connect_error()); } echo "connection sucsefful"; mysqli_close($conn); ?>

and this for check

<?php include "koneksi.php"; function anti_injection($data){ $filter = mysqli_real_escape_string(stripslashes(strip_tags(htmlspecialchars($data,ENT_QUOTES)))); return $filter; } $username = anti_injection($_POST['username']); $pass = anti_injection(md5($_POST['password'])); // be sure username and password is capital or number. if (!ctype_alnum($username) OR !ctype_alnum($pass)){ echo "now login cannot injection."; } else{ $login=mysqli_query("SELECT * FROM users WHERE username='$username' AND password='$pass' AND blokir='N'"); $ketemu=mysqli_num_rows($login); $r=mysqli_fetch_array($login); // If username and password found if ($ketemu > 0){ session_start(); $_SESSION[namauser] = $r[username]; $_SESSION[namalengkap] = $r[nama_lengkap]; $_SESSION[passuser] = $r[password]; $_SESSION[leveluser] = $r[level]; $sid_lama = session_id(); session_regenerate_id(); $sid_baru = session_id(); mysqli_query("UPDATE users SET id_session='$sid_baru' WHERE username='$username'"); header('location:halaman_utama.php'); } else{ echo "Login failed!
Username or Password wrong.
"; echo "try again"; } } ?>

#2

Hi @Irwan

You have to find your username and database name first

Log into your cpanel -> Choose the website -> Manage database

There’s your username and database name. Reply $username and $database with them.

If you haven’t create a database create one first