I made a simple login form for my website using php. (actualy I downloaded a pre-made one). I followed all the instructions but there was no mention of a solution to this problem. When I try to login or register this shows up ‘Database Login failed! Please make sure that the DB login credentials provided are correct. Mysqlerror:Connection refused. Database login failed!’. I don’t know anything about databases, please help.
The answer is in your original message: Please make sure that the DB login credentials provided are correct.
Check your script configuration and the MySQL Databases section in the control panel. Do all the credentials match? Be sure to configure the hostname as well, plenty of people forget that step.
I had a look at the mySQL databases section and it seems ok. I’ll check again just to make sure. I’m not sure however, how to configure the hostname. Thankyou.
@HaCk3r said:
I had a look at the mySQL databases section and it seems ok. I’ll check again just to make sure. I’m not sure however, how to configure the hostname. Thankyou.
In that case, making sure the correct hostname is used is probably the next best step. Whatever default value the script uses, it’s not correct.
This is probably very obvious but what is the default value? Sorry but I know very little about PHP.
@HaCk3r said:
This is probably very obvious but what is the default value? Sorry but I know very little about PHP.
Most scripts use localhost
as their default value, meaning it’s going to look for a database on the same server as your website is. However, we host our databases on separate, faster servers, which means localhost
isn’t going to work. The correct database hostname can be found in your control panel.
Just to make sure. Do I simply replace ‘localhost’ in the code with the writing in the ‘MySQL hostname’ section in the controll panel? Sorry, I’m new to this.
@HaCk3r said:
Just to make sure. Do I simply replace ‘localhost’ in the code with the writing in the ‘MySQL hostname’ section in the controll panel? Sorry, I’m new to this.
What happened when you tried?
I used a program to find ‘localhost’ in the files. It didn’t find the word localhost.
@HaCk3r said:
I used a program to find ‘localhost’ in the files. It didn’t find the word localhost.
I don’t know what script you’re using, let alone know how it works. Just make sure the database details are correct.
However, I did find the file htdocs/chat-room-1/config.php:
<?php
define("mysqlServer","localhost");
define("mysqlDB","mysqlDB");
define("mysqlUser","mysqlUser");
define("mysqlPass","mysqlPass");
That looks like something which should be filled it but hasn’t been.
Oh, that’s the chat. I haven’t finished with it yet but yes, it does look like like it should be filled in. About the login (located in htdocs/security/source if you want to have a look at the code) maby the script looks for a database in ‘localhost’ by default so it hasn’t been specified. That’s why it’s not in the code. If the database is not in ‘localhost’ maby you have to specify this in the code. If so, where should I specify this?
@HaCk3r said:
Oh, that’s the chat. I haven’t finished with it yet but yes, it does look like like it should be filled in. About the login (located in htdocs/security/source if you want to have a look at the code) maby the script looks for a database in ‘localhost’ by default so it hasn’t been specified. That’s why it’s not in the code. If the database is not in ‘localhost’ maby you have to specify this in the code. If so, where should I specify this?
I think you need to specify it in htdocs/security/source/include/membersite_config.php. You are calling initDB there with some parameters, but none of those look like valid database credentials.
About what you said before about the chat room config. What should I put in the last two sections?
define(“mysqlUser”,“…”);
define(“mysqlPass”,“…”);
@HaCk3r said:
About what you said before about the chat room config. What should I put in the last two sections?define(“mysqlUser”,“…”);
define(“mysqlPass”,“…”);
The MySQL username and password are the same as the username and password for FTP.
I found another login page. This time when I press login, it says that it cannot connect to the database. I found a section in the connect.php file where it said “$connection = mysqli_connect(‘localhost’, ‘root’, ‘’);” I replaced localhost with the MySQL hostname but the result was still thesame. As I do not know much about MySQL I’m not sure how to fix this problem.
@HaCk3r said:
I found another login page. This time when I press login, it says that it cannot connect to the database. I found a section in the connect.php file where it said “$connection = mysqli_connect(‘localhost’, ‘root’, ‘’);” I replaced localhost with the MySQL hostname but the result was still thesame. As I do not know much about MySQL I’m not sure how to fix this problem.
Check what the parameters mean in the PHP documentation and think what they should be. Hint: ‘root’ is not correct.
So do I just replace ‘root’ with the MySQL username and in the blank ‘’ write my MySQL password?
I tried that and this is the result: Cannot select database.Access denied for user ‘rfgd_19745312’@‘192.168.0.%’ to database ‘cc’.
Please could you check connect.php? I filled everything with what I think, is the corresponding code but the result remains unchanged, furthermore, after reloading it went back to Cannot connect to database.
@HaCk3r said:
I tried that and this is the result: Cannot select database.Access denied for user ‘rfgd_19745312’@‘192.168.0.%’ to database ‘cc’.
Check the database name, cc
is not a valid database name.