Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

General Discussion

Ben Quartermaine
Ben Quartermaine
14,966 Points

Connecting mySQL database

I'm having trouble setting up a connection to a phpMyAdmin database I have created. I am trying to create a sign up page. When a user enters their username and password I want the database to be updated. I'm getting the following error messages:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'root@localhost' (Using password: NO) in W:\www\signup.php on line 2

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in W:\www\signup.php on line 3

Warning: mysql_query() [function.mysql-query]: Access denied for user: 'ODBC@localhost' (Using password: NO) in W:\www\signup.php on line 10

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in W:\www\signup.php on line 10 FailedAccess denied for user: 'ODBC@localhost' (Using password: NO)

Here is my code...

    $conn = mysql_connect("localhost","root","");
    $db   = mysql_select_db("loginpage", $conn);

    $user = $_POST['n'];
    $pass = $_POST['p'];
    $sql = "INSERT into phplogin VALUES(".$user.",'".$pass."')";
    $query = mysql_query($sql);

        echo "Failed".mysql_error();
        echo "Successful!";

1 Answer