mysqli_query() 至少需要 2 个参数,1 个给定
这个 mysqli_query
命令导致下面的错误
mysqli_query("INSERT INTO `counter`.`hits` (`page_hits`) VALUES (1)");
<块引用>
警告:mysqli_query() 至少需要 2 个参数,其中 1 个给出
此错误消息是什么意思,如何解决?
解决方案您需要在页面前面的某个位置指定您与数据库建立的连接.您应该将该变量放入查询中.假设您创建了一个名为 $con
的变量.那么你的代码应该是这样的.
mysqli_query($con,"INSERT INTO `counter`.`hits` (`page_hits`) VALUES (1)");
This mysqli_query
command results in the error below
mysqli_query("INSERT INTO `counter`.`hits` (`page_hits`) VALUES (1)");
Warning: mysqli_query() expects at least 2 parameters, 1 given in
What does this error message mean, and how can it be fixed?
解决方案You need to specify the connection that you made to your database somewhere earlier in your page. You should put that variable in the query. Suppose you made a variable called $con
. Then your code should be like this.
mysqli_query($con,"INSERT INTO `counter`.`hits` (`page_hits`) VALUES (1)");
相关文章