Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES)

Cheryl Perry

Warning: mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\Login\sessionHandler.php on line 35

So this is what's on the line 35.

//to make a connection with database
$conn = mysql_connect("localhost", "root", "password") or die(mysql_error());

I don't know whether this is the problem or the code I'm writing. I have searched for every possible answer but it is not what I was looking for.

this is my code (if the problem is not really on the line 35)

//validation error flag
$errflag = false;

//Input Validation
if($_POST['uname'] == '')
{
    $errmsg_arr[]='Login ID missing';
    $errflag = true;
}
if($_POST['pword'] == '')
{
    $errmsg_arr[] = 'Password missing';
    $errflag = true;
}


//if there are input validations, redirect back to the login form
if($errflag)
{
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    session_write_close();
    header("location: login.php");
    exit();
}

//to make a connection with database
$conn = mysql_connect("localhost", "root", "password") or die(mysql_error());


//to select the targeted database
mysql_select_db("ngchoonching", $conn) or die(mysql_error());

//to create a query to be executed in sql
$username = $_POST['uname'];
$password = $_POST['pword'];
$query = "SELECT * FROM profile WHERE username = '$username' AND password = '$password'";

//to run sql query in database
$result= mysql_query($query, $conn) or die(mysql_error());

//check whether the query was successful or not
if(isset($result))
{
    if(mysql_num_rows($result) == 1)
    {
        //Login successful
        session_regenerate_id();
        $member = mysql_fetch_assoc($result);
        $_SESSION['SESS_MEMBER_ID'] = $member['id'];
        $_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
        $_SESSION['SESS_LAST_NAME'] = $member['lastname'];
        $_SESSION['STATUS'] = true;
        session_write_close();
        header("location: login-successful.php");
        exit();
    }
    else
    {
        //login failed
        header("location: login-failed.html");
        exit();
    }
}
else
{
    die("Query failed");
}

?>

I use localhost,phpmyadmin,xampp and I don't understand why the access is denied.

onedevteam.com

try $conn = mysql_connect("localhost", "root") or $conn = mysql_connect("localhost", "root", "")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

From Java

Access Denied for User 'root'@'localhost' (using password: YES) - No Privileges?

From Dev

mysql_connect(): Access denied for user 'user'@'host' (using password: NO)

From Dev

PyCharm - Database connection. Access denied for user 'root'@'localhost' (using password: YES)

From Dev

Access denied for user 'root'@'localhost' (using password: Yes) after password reset LINUX

From Dev

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

From Dev

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES)

From Dev

Access denied for user 'root'@'localhost' (using password: YES)

From Dev

Access denied for user 'root'@'localhost' (using password: NO);

From Dev

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2

From Dev

ajax with jsp and mysql : java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

From Dev

Php Post Insert Error Access denied for user 'root'@'localhost' (using password: YES)

From Dev

OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

From Dev

Laravel Access denied for user 'root'@'localhost' (using password: YES) in laravel 4.2

From Dev

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

From Dev

error: 'Access denied for user 'root'@'localhost' (using password: YES)'

From Dev

Locall MySQL DB login Error : Access denied for user 'root'@'localhost' (using password: YES)

From Dev

Could not connect to Database: Access denied for user '***'@'localhost' (using password: YES)

From Dev

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2

From Dev

lavaral 5 ERROR{ (SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)}

From Dev

c3p0 access denied for user 'root'@'localhost' (using password yes)

From Dev

MySQL Access denied for user 'User'@'localhost' (using password: YES)

From Dev

Unable to access MySQL from C# application because of Exception: "Access denied for user 'root'@'localhost' (using password: YES)"

From Dev

OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

From Dev

mysql_connect(): Access denied for user 'root'@'localhost'

From Dev

Access denied for user 'root'@'%' (using password: YES) but logged in as root

From Dev

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) after set plugin = ''

From Dev

rails db:migrate rails aborted! Mysql2::Error: Access denied for user 'root'@'localhost' (using password: YES)

From Dev

Brew mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Related Related

  1. 1

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

  2. 2

    Access Denied for User 'root'@'localhost' (using password: YES) - No Privileges?

  3. 3

    mysql_connect(): Access denied for user 'user'@'host' (using password: NO)

  4. 4

    PyCharm - Database connection. Access denied for user 'root'@'localhost' (using password: YES)

  5. 5

    Access denied for user 'root'@'localhost' (using password: Yes) after password reset LINUX

  6. 6

    java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

  7. 7

    Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES)

  8. 8

    Access denied for user 'root'@'localhost' (using password: YES)

  9. 9

    Access denied for user 'root'@'localhost' (using password: NO);

  10. 10

    SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2

  11. 11

    ajax with jsp and mysql : java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

  12. 12

    Php Post Insert Error Access denied for user 'root'@'localhost' (using password: YES)

  13. 13

    OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

  14. 14

    Laravel Access denied for user 'root'@'localhost' (using password: YES) in laravel 4.2

  15. 15

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

  16. 16

    error: 'Access denied for user 'root'@'localhost' (using password: YES)'

  17. 17

    Locall MySQL DB login Error : Access denied for user 'root'@'localhost' (using password: YES)

  18. 18

    Could not connect to Database: Access denied for user '***'@'localhost' (using password: YES)

  19. 19

    SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2

  20. 20

    lavaral 5 ERROR{ (SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)}

  21. 21

    c3p0 access denied for user 'root'@'localhost' (using password yes)

  22. 22

    MySQL Access denied for user 'User'@'localhost' (using password: YES)

  23. 23

    Unable to access MySQL from C# application because of Exception: "Access denied for user 'root'@'localhost' (using password: YES)"

  24. 24

    OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

  25. 25

    mysql_connect(): Access denied for user 'root'@'localhost'

  26. 26

    Access denied for user 'root'@'%' (using password: YES) but logged in as root

  27. 27

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) after set plugin = ''

  28. 28

    rails db:migrate rails aborted! Mysql2::Error: Access denied for user 'root'@'localhost' (using password: YES)

  29. 29

    Brew mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

HotTag

Archive