$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);
}
}
}
資料庫WA成功創建,字元集也修改了。但數據表沒能創建成功。
報錯:Commands out of sync; you can't run this command now
百度了下沒找到解決方法,說是得先清空結果集,試了下也沒成功。請大神幫忙。
錯誤明顯是從第14行開始的。在14行前面應該要釋放什麼東西,請問這個東西要怎麼釋放。
multi_query,別用這個吧