Search code examples
phpmysqlhtmlmysql-error-1045

Database Login Failed, Mysql, html, and php


I am trying to work on getting better at making HTML forms using PHP and Mysql databases so I decided to make a little mock-up website to do some experiments and things like that.

I decided that the first thing I would need to do was to create a login and register page for users who want to sign on to the website. I had no idea how to do this so I did a little research online and I found some pre-built scripts that would do exactly what I wanted to do. In the end I decided to go with this script: http://www.html-form-guide.com/php-form/php-registration-form.html

On my website (hosted with hostgator using cPanel) I set up a Mysql database called ljbaumer_gifts (website is a gift website) and I added a table with 2 columns. The first one a login column which was set to int with auto increment and 25 characters. The second one is a password one which was set to var_char and 25 characters.

I filled in all of the information on the setup scripts from the website I linked to earlier completely correctly but every single time I try to register I get this error code:

Database Login failed! Please make sure that the DB login credentials provided are correct mysqlerror:Access denied for user 'ljbamer_root'@'my_server_adress' (using password: YES) Database login failed!

I used an account that has complete privileges on my server but it still doesn't work!


Solution

  • Seems like you have trouble with connection string. In your Hostgator Control panel You have to follow this steps.

    1. Create Database
    2. Create User
    3. Add User To Database
    4. Give a user permissions to a database
    5. Save your settings.

    Now u can use Created Database, And User Credentials of USER assigned to your database. Things will work fine afterwards.

    Thanks.