php - How to resolve "Access denied for user X" errors in MySQL? -


error:

warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): access denied user 'rohit'@'localhost' (using password: yes) in c:\xampp\htdocs\myprograms\db.php on line 8 connection failed: access denied user 'rohit'@'localhost' (using password: yes)

code:

if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); }   $sql = "select cid, fname, lname face"; $result = $conn->query($sql);  if ($result->num_rows > 0) {  while($row = $result->fetch_assoc()) { echo "<br> id: ". $row["id"]. " - name: ". $row["firstname"]. " " .      $row["lastname"] . "<br>"; } } else { echo "0 results"; }  $conn->close(); ?>   

this because try use incorrect username, password or host. try create new user phpmyadmin page:

open "users" tab > select global privileges checkboxes > type new user name, host , password , click "go" button.

after try set new username, password , host in new mysqli() constructor.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -