how can I creates a mysqli database for first the first time?

后端 未结 2 594
半阙折子戏
半阙折子戏 2021-01-22 19:03

I was running an example from a mysqli tutorial.

$mysqli = new mysqli(\"localhost\", \"user\", \"password\", \"database\");
if($mysqli->connect_errno)
{
  ech         


        
相关标签:
2条回答
  • 2021-01-22 19:35

    You have to use this:

    $mysqli=new mysqli("localhost","user","password") or die(".........");
    
    if($mysqli->query("Create database if not exists MyDB")){
    
       "Failed creating new database: ".$mysqli->connect_errno();
        die();
    
    }
    
    $mysqli->select_db("MyDB");
    $mysqli->close();
    
    0 讨论(0)
  • 2021-01-22 19:40

    try something like this

    $mysqli = new mysqli("localhost", "user", "password");
    

    in this way you are connected to database

    and put this query using mysqli Create Database database1

    0 讨论(0)
提交回复
热议问题