Error 1044

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Error 1044

Postby mateic_09 » 21. August 2021 19:38

Hi!I tried to connect a PHP script to a database(called eu).I checked all privileges for user root,the one I use in PHP ,but I get this error:"Array ( [0] => Array ( [errno] => 1044 [sqlstate] => 42000 [error] => Access denied for user ''@'localhost' to database 'eu' ) ) 1".Please help!

Code:<?php
/* db.php contains these $dbname = "eu";
$dbusername = "root";
$dbpassword = "";
$dbsrvname = "localhost";*/


include('..\db.php');
$con = mysqli_connect($dbsrvname, $dbusername, $dbpassword, $dbname);
if (!$con){
echo('Connection ERROR');
die(print_r(mysqli_error($con)));
}
$query="USE eu";
$stms=mysqli_query($con,$query);
$x=$_POST['username'];
$y=$_POST['password'];

if ($stms === false){
echo('ERROR during query execution: ');
die(print_r($con->error_list));
}
$row = mysqli_fetch_array($stms, MYSQLI_ASSOC);
if ($row){
die('Logged in');
}
else{
die('Wrong username or password');
}
?>
mateic_09
 
Posts: 5
Joined: 27. July 2021 11:14
XAMPP version: 8.0.8
Operating System: linux

Re: Error 1044

Postby Nobbie » 22. August 2021 10:42

Seems that dp.php resets the value of $dbusername, please show us the code of db.php
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Re: Error 1044

Postby mateic_09 » 22. August 2021 14:23

$dbname = "eu";
$dbusername = "root";
$dbpassword = "";
$dbsrvname = "localhost";
mateic_09
 
Posts: 5
Joined: 27. July 2021 11:14
XAMPP version: 8.0.8
Operating System: linux


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 45 guests