ionezation Posted November 22, 2013 Share Posted November 22, 2013 Hi, I am stuck at this place at chapter 17 Message Board. When connecting to database it gives this error could not connect to database access denied for user 'user'@'localhost' (using password yes) in mysqli_connect.php DEFINE ("DB_USER","root") DEFINE ("DB_PASSWORD","") DEFINE ("DB_HOST","localhost") DEFINE ("DB_NAME","forum2") $connect = @mysqli_connect(DB_USER,DB_PASSWORD,DB_HOST,DB_NAME) or die ('Could Not Connect to Database:'. mysqli_connect_error() ) ; mysqli_set_charset($connect, 'utf-8'). I have also changed the position of user name local host password but nothing works. What I do I cant figure it out. Please help. One thing more I am not getting the idea that why $_SESSION = array(); is uncommented to virtually log the user out? how it is possible ?? on page 530 chapter 17 'Message Board Regards, Anu' Link to comment Share on other sites More sharing options...
Larry Posted November 22, 2013 Share Posted November 22, 2013 As for the connection issue, your script that's trying to connect must not be including the right mysqli_connect.php file as the code you've posted uses "root" as the user and that's not what's being used for the connection. As for $_SESSION=array();, if that line is executed, it logs the user out because it clears out the session values. Link to comment Share on other sites More sharing options...
ionezation Posted November 23, 2013 Author Share Posted November 23, 2013 you meant I should left the username field blank?? I am including it this way require('mysqli_connect.php'); is that correct?? if $_SESSION=array(); executed then how the other script will run ? I mean if we want to log out then we have to uncomment it? otherwise the user will stay logged in?? Link to comment Share on other sites More sharing options...
Larry Posted November 25, 2013 Share Posted November 25, 2013 No, not what I meant. My point is that if your mysqli_connect.php script does this: DEFINE ("DB_USER","root") But your error message is this: "could not connect to database access denied for user 'user'@'localhost' (using password yes)" Then you're trying to connect to MySQL as "user", not as "root". Something is amiss there. As for $_SESSION = array(); that's a temporary and manual way of logging the user out until you create a logout script. Link to comment Share on other sites More sharing options...
Recommended Posts