简体   繁体   中英

Webmatrix Access denied for user ''@'localhost' (using password: NO)

I have a problem with a mysqli_query in this code:

  <?php

  session_start();
  $user = $_POST['user'];
  $pwd = $_POST['pwd'];
  include "connect.php";


  if ($user && $pwd){

  // infos provided
  $queryget=mysqli_query("SELECT * FROM Tmembers WHERE user='$user' AND pwd='$pwd'");
  $numrows=mysqli_num_rows("$queryget");

 if ($numrows !=0){
                    $_SESSION['user'] =$user;
                    echo "you have successfully logged in .";
                  }

 else echo "you r not a member, please sign in  ";
               }

                else{
                        echo "you didn't enter any entries !!!";
                        include "connect.php";
                     }
  ?>

it returns this error : Access denied for user ''@'localhost' (using password: NO)

I am working on webmatrix, with a Mysql database not (sql server) and I connected to it successfuly via connect.php, and it has a password, the table Tmembers has two colomns user and pwd, I don't know how to fix this access bug

The error states no password was specified even though it exists in the code. So basically the error does not match the statement mysqli_connect("localhost", "root"... which means the database thinks you aren't even attempting to connect in the first place.

Try replacing mysqli_connect() with mysql_connect() see if that helps.

The first parameter of mysqli_query should be the connection resource from your connect statement. Then pass your sql query string as a second parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM