Jump to content

Could not connect to db


Moez

Recommended Posts

Even if you did have to include the host (which you don't), what on earth is

locahhost'@'root

What is “locahhost”? Where are the closing quotes? Why is your format host@user instead of user@host?

 

Please, Moez. At least read your code before you ask others to fix it. And it doesn't hurt to write down a proper error description instead of just dumping the code. Lazy people aren't exactly popular in help forums.

you are putting a space on the end of the DB_USERNAME defined constant. if your code (for debugging/learning) was making use the php warning from that statement or the mysqli_connect_error() message you would probably be able to see it in the error message - 

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

in programming, every character matters and in this case an extra character that's not present in the actual value causes the connection to fail. this is no different than if your code had define("DB_USERNAME", "roota");. that's not what the username is.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.