How to fix the error: “Connection failed: Access denied for user 'username'@'servername' (using password:...












0















I am trying to implement a login system on my website and therefore I need to connect a php file to a mySQL database. One problem, I keep getting this error:



Connection failed: Access denied for user 'username'@'servername' (using password: NO)



Does anyone know how to fix this error? Or can anyone tell me what I'm doing wrong?



I know this question has been asked like a million times already, but none of those answers have worked for me. They all are solutions for a local server and database, where mine is at a webhost so i think this works different.



Here's my code:



<?php

$servername = "servername";
$dBUsername = "db username";
$dBPassword = "db passwordd";
$dBName = "db name";
$dBPort = "db port";

$conn = new mysqli($servername, $dBUsername, $dPassword, $dBName, $dBPort);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}









share|improve this question

























  • Try dropping the port.

    – Funk Forty Niner
    Dec 28 '18 at 2:32











  • Are you trying to connect to a remote database server?

    – catcon
    Dec 28 '18 at 2:32











  • Did you create password for the username in your remote database server? Where did you host the php file that connects to the database?

    – McBern
    Dec 28 '18 at 2:39











  • Reference: Warning: mysql_connect(): Access denied for user 'name'@'host'

    – mario
    Dec 28 '18 at 2:41






  • 1





    @FunkFortyNiner okay. That's also an answer what helps me ; P. I just didn't know what the problem was.

    – Rien Klapwijk
    Dec 28 '18 at 17:51
















0















I am trying to implement a login system on my website and therefore I need to connect a php file to a mySQL database. One problem, I keep getting this error:



Connection failed: Access denied for user 'username'@'servername' (using password: NO)



Does anyone know how to fix this error? Or can anyone tell me what I'm doing wrong?



I know this question has been asked like a million times already, but none of those answers have worked for me. They all are solutions for a local server and database, where mine is at a webhost so i think this works different.



Here's my code:



<?php

$servername = "servername";
$dBUsername = "db username";
$dBPassword = "db passwordd";
$dBName = "db name";
$dBPort = "db port";

$conn = new mysqli($servername, $dBUsername, $dPassword, $dBName, $dBPort);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}









share|improve this question

























  • Try dropping the port.

    – Funk Forty Niner
    Dec 28 '18 at 2:32











  • Are you trying to connect to a remote database server?

    – catcon
    Dec 28 '18 at 2:32











  • Did you create password for the username in your remote database server? Where did you host the php file that connects to the database?

    – McBern
    Dec 28 '18 at 2:39











  • Reference: Warning: mysql_connect(): Access denied for user 'name'@'host'

    – mario
    Dec 28 '18 at 2:41






  • 1





    @FunkFortyNiner okay. That's also an answer what helps me ; P. I just didn't know what the problem was.

    – Rien Klapwijk
    Dec 28 '18 at 17:51














0












0








0








I am trying to implement a login system on my website and therefore I need to connect a php file to a mySQL database. One problem, I keep getting this error:



Connection failed: Access denied for user 'username'@'servername' (using password: NO)



Does anyone know how to fix this error? Or can anyone tell me what I'm doing wrong?



I know this question has been asked like a million times already, but none of those answers have worked for me. They all are solutions for a local server and database, where mine is at a webhost so i think this works different.



Here's my code:



<?php

$servername = "servername";
$dBUsername = "db username";
$dBPassword = "db passwordd";
$dBName = "db name";
$dBPort = "db port";

$conn = new mysqli($servername, $dBUsername, $dPassword, $dBName, $dBPort);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}









share|improve this question
















I am trying to implement a login system on my website and therefore I need to connect a php file to a mySQL database. One problem, I keep getting this error:



Connection failed: Access denied for user 'username'@'servername' (using password: NO)



Does anyone know how to fix this error? Or can anyone tell me what I'm doing wrong?



I know this question has been asked like a million times already, but none of those answers have worked for me. They all are solutions for a local server and database, where mine is at a webhost so i think this works different.



Here's my code:



<?php

$servername = "servername";
$dBUsername = "db username";
$dBPassword = "db passwordd";
$dBName = "db name";
$dBPort = "db port";

$conn = new mysqli($servername, $dBUsername, $dPassword, $dBName, $dBPort);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}






php mysql database connection hosted






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 28 '18 at 18:07









Funk Forty Niner

80.6k1247102




80.6k1247102










asked Dec 28 '18 at 2:14









Rien KlapwijkRien Klapwijk

33




33













  • Try dropping the port.

    – Funk Forty Niner
    Dec 28 '18 at 2:32











  • Are you trying to connect to a remote database server?

    – catcon
    Dec 28 '18 at 2:32











  • Did you create password for the username in your remote database server? Where did you host the php file that connects to the database?

    – McBern
    Dec 28 '18 at 2:39











  • Reference: Warning: mysql_connect(): Access denied for user 'name'@'host'

    – mario
    Dec 28 '18 at 2:41






  • 1





    @FunkFortyNiner okay. That's also an answer what helps me ; P. I just didn't know what the problem was.

    – Rien Klapwijk
    Dec 28 '18 at 17:51



















  • Try dropping the port.

    – Funk Forty Niner
    Dec 28 '18 at 2:32











  • Are you trying to connect to a remote database server?

    – catcon
    Dec 28 '18 at 2:32











  • Did you create password for the username in your remote database server? Where did you host the php file that connects to the database?

    – McBern
    Dec 28 '18 at 2:39











  • Reference: Warning: mysql_connect(): Access denied for user 'name'@'host'

    – mario
    Dec 28 '18 at 2:41






  • 1





    @FunkFortyNiner okay. That's also an answer what helps me ; P. I just didn't know what the problem was.

    – Rien Klapwijk
    Dec 28 '18 at 17:51

















Try dropping the port.

– Funk Forty Niner
Dec 28 '18 at 2:32





Try dropping the port.

– Funk Forty Niner
Dec 28 '18 at 2:32













Are you trying to connect to a remote database server?

– catcon
Dec 28 '18 at 2:32





Are you trying to connect to a remote database server?

– catcon
Dec 28 '18 at 2:32













Did you create password for the username in your remote database server? Where did you host the php file that connects to the database?

– McBern
Dec 28 '18 at 2:39





Did you create password for the username in your remote database server? Where did you host the php file that connects to the database?

– McBern
Dec 28 '18 at 2:39













Reference: Warning: mysql_connect(): Access denied for user 'name'@'host'

– mario
Dec 28 '18 at 2:41





Reference: Warning: mysql_connect(): Access denied for user 'name'@'host'

– mario
Dec 28 '18 at 2:41




1




1





@FunkFortyNiner okay. That's also an answer what helps me ; P. I just didn't know what the problem was.

– Rien Klapwijk
Dec 28 '18 at 17:51





@FunkFortyNiner okay. That's also an answer what helps me ; P. I just didn't know what the problem was.

– Rien Klapwijk
Dec 28 '18 at 17:51












1 Answer
1






active

oldest

votes


















0














The variable name you are using in the password parameter slot is not the same as the one you defined above ($dBPassword vs $dPassword):



$dBPassword = "db passwordd";
// ...
$conn = new mysqli($servername, $dBUsername, $dPassword, $dBName, $dBPort);


In PHP the undefined variable "$dPassword" will be treated as a NULL which is likely why you're getting that "using password: NO" in the returned error.






share|improve this answer
























  • Ohw really. I feel so dumb right now. Thanks. It works. :P

    – Rien Klapwijk
    Dec 28 '18 at 19:07











  • @RienKlapwijk, don't be too hard on yourself. We all need a fresh set of eyes from time to time.

    – jpheldson
    Dec 28 '18 at 19:10











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53952965%2fhow-to-fix-the-error-connection-failed-access-denied-for-user-usernameser%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The variable name you are using in the password parameter slot is not the same as the one you defined above ($dBPassword vs $dPassword):



$dBPassword = "db passwordd";
// ...
$conn = new mysqli($servername, $dBUsername, $dPassword, $dBName, $dBPort);


In PHP the undefined variable "$dPassword" will be treated as a NULL which is likely why you're getting that "using password: NO" in the returned error.






share|improve this answer
























  • Ohw really. I feel so dumb right now. Thanks. It works. :P

    – Rien Klapwijk
    Dec 28 '18 at 19:07











  • @RienKlapwijk, don't be too hard on yourself. We all need a fresh set of eyes from time to time.

    – jpheldson
    Dec 28 '18 at 19:10
















0














The variable name you are using in the password parameter slot is not the same as the one you defined above ($dBPassword vs $dPassword):



$dBPassword = "db passwordd";
// ...
$conn = new mysqli($servername, $dBUsername, $dPassword, $dBName, $dBPort);


In PHP the undefined variable "$dPassword" will be treated as a NULL which is likely why you're getting that "using password: NO" in the returned error.






share|improve this answer
























  • Ohw really. I feel so dumb right now. Thanks. It works. :P

    – Rien Klapwijk
    Dec 28 '18 at 19:07











  • @RienKlapwijk, don't be too hard on yourself. We all need a fresh set of eyes from time to time.

    – jpheldson
    Dec 28 '18 at 19:10














0












0








0







The variable name you are using in the password parameter slot is not the same as the one you defined above ($dBPassword vs $dPassword):



$dBPassword = "db passwordd";
// ...
$conn = new mysqli($servername, $dBUsername, $dPassword, $dBName, $dBPort);


In PHP the undefined variable "$dPassword" will be treated as a NULL which is likely why you're getting that "using password: NO" in the returned error.






share|improve this answer













The variable name you are using in the password parameter slot is not the same as the one you defined above ($dBPassword vs $dPassword):



$dBPassword = "db passwordd";
// ...
$conn = new mysqli($servername, $dBUsername, $dPassword, $dBName, $dBPort);


In PHP the undefined variable "$dPassword" will be treated as a NULL which is likely why you're getting that "using password: NO" in the returned error.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 28 '18 at 18:15









jpheldsonjpheldson

685512




685512













  • Ohw really. I feel so dumb right now. Thanks. It works. :P

    – Rien Klapwijk
    Dec 28 '18 at 19:07











  • @RienKlapwijk, don't be too hard on yourself. We all need a fresh set of eyes from time to time.

    – jpheldson
    Dec 28 '18 at 19:10



















  • Ohw really. I feel so dumb right now. Thanks. It works. :P

    – Rien Klapwijk
    Dec 28 '18 at 19:07











  • @RienKlapwijk, don't be too hard on yourself. We all need a fresh set of eyes from time to time.

    – jpheldson
    Dec 28 '18 at 19:10

















Ohw really. I feel so dumb right now. Thanks. It works. :P

– Rien Klapwijk
Dec 28 '18 at 19:07





Ohw really. I feel so dumb right now. Thanks. It works. :P

– Rien Klapwijk
Dec 28 '18 at 19:07













@RienKlapwijk, don't be too hard on yourself. We all need a fresh set of eyes from time to time.

– jpheldson
Dec 28 '18 at 19:10





@RienKlapwijk, don't be too hard on yourself. We all need a fresh set of eyes from time to time.

– jpheldson
Dec 28 '18 at 19:10


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53952965%2fhow-to-fix-the-error-connection-failed-access-denied-for-user-usernameser%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas