我正在尝试将我的MySQL代码转换为MYSQLI,但它在第21行出错。我无法识别我必须纠正第21行错误。有人可以帮帮我吗?
$conn = mysqli_connect($host,$username,$password) or die(mysqli_error());
mysqli_select_db($conn,$dbname) or die(mysqli_error());
mysqli_set_charset($conn , "utf8");
mysqli_query($conn,"CREATE TABLE IF NOT EXISTS `cookies` (
`ip` varchar(32) NOT NULL DEFAULT '',
`time` varchar(32) DEFAULT NULL,
`waktu` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ip`)
ENGINE=MyISAM DEFAULT CHARSET=utf8;
)
");
答案 0 :(得分:0)
您的mysqli_error
应该有一个参数。 mysqli_error($connection)
此处编辑的代码:
$conn = mysqli_connect($host,$username,$password);
mysqli_select_db($conn,$dbname) or die(mysqli_error($conn));
mysqli_set_charset($conn , "utf8");
mysqli_query($conn,"CREATE TABLE IF NOT EXISTS `cookies` (
`ip` varchar(32) NOT NULL DEFAULT '',
`time` varchar(32) DEFAULT NULL,
`waktu` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ip`)
ENGINE=MyISAM DEFAULT CHARSET=utf8;
)
");