mysqli_query() 需要至少 2 个参数,1 个给定 [英] mysqli_query() expects at least 2 parameters, 1 given

查看:35
本文介绍了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)"); 

这篇关于mysqli_query() 需要至少 2 个参数,1 个给定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆