php - The database WA was created successfully, but the data table was not successfully created. An error was reported: Commands out of sync.
黄舟
黄舟 2017-05-16 12:59:29
0
1
550
    $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.

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
过去多啦不再A梦

multi_query, don’t use this

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template