Error No Database Selected PHP/mySQL

后端 未结 1 1389
抹茶落季
抹茶落季 2021-01-25 06:40

I have read a bunch of the other posts about similar issues but I am very new to this so I am likely missing something. Most of the other questions I found were a lot more compl

相关标签:
1条回答
  • 2021-01-25 07:08

    You should follow the proper syntax:

    $conn = mysqli_connect(<host Name>, <username>, <password>, <database name>);
    

    Reference: http://php.net/manual/en/function.mysqli-connect.php#refsect1-function.mysqli-connect-examples

    Add two more parameters- username and password here:

    $username = "root";  // Default values
    $password = "";      // Default values
    
    $conn = mysqli_connect($servername, $username, $password, $dbname);
    
    0 讨论(0)
提交回复
热议问题