想在php创建个数据库,结果创建失败,代码及错因如下,求大神指点

<?php

header("content-type:text/html;charset=utf-8");

$mq=mysqli_connect('localhost','root','');

if(!$mq){

echo "链接失败";

}

else{

echo "链接成功";

}

if(mysql_query("CREATE DATABASE animal",$mq)){

echo "创建成功";

}else{

echo "创建失败";

}

?>

错因: Warning: mysql_query() expects parameter 2 to be resource, object given in D:\WAMPServer\wamp\www\phptext\phptext1\mysqltext.php on line10

慕盖茨2165817
浏览 2809回答 1
1回答

KevenHuang

第三行写错了$mq=mysqli_connect(&#039;localhost&#039;,&#039;root&#039;,&#039;&#039;);用mysqli扩展连接的数据库却用了mysql_query能不错吗?
打开App,查看更多内容
随时随地看视频慕课网APP