search

Home  >  Q&A  >  body text

php - The database WA was created successfully, but the data table was not successfully created. An error was reported: Commands out of sync.

    $conn = new mysqli($serverName, $MYSQLUserName, $MYSQLPwd);
    $sql = "use WA";
    if($conn->query($sql)){
    }   else{
        if($conn->error == "Unknown database 'wa'"){
            $sqlCreateDatabase = "create database WA;";
            $sqlCreateDatabase .= "alter database WA character set utf8;";
            $conn->multi_query($sqlCreateDatabase);
            $sqlCreateTable = "create table userInfo(
                 id smallint unsigned primary key auto_increment,
                 userName varchar(30),
                 pwd varchar(6)
             );";
             if($conn->query($sqlCreateTable)){
                echo("success");
             }  else{
                echo($conn->error);
             }
        }
    }

Database WA was successfully created and the character set was also modified. But the data table could not be created successfully.
Error: Commands out of sync; you can't run this command now
Baidu did not find a solution. It said that the result set must be cleared first, but it did not succeed. Please help me.

The error obviously starts on line 14. Something should be released before line 14. Please tell me how to release this thing.

黄舟黄舟2818 days ago569

reply all(1)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 13:01:29

    multi_query, don’t use this

    reply
    0
  • Cancelreply