警告:mysqli_query()期望参数1为mysqli,在我正在尝试构建一个简单的自定义CMS,但是我得到了一个错误:警告:mysqli_query()期望参数1为MySQLi,在我为什么要犯这个错误?我的所有代码都是MySQLi,我使用的是两个参数,而不是一个。$con=mysqli_connect("localhost","xxxx","xxxx","xxxxx");//check connectionif (mysqli_connect_errno($con)){echo "Failed to connect to MySQL:" .
mysqli_connect_error();}function getPosts() {$query = mysqli_query($con,"SELECT * FROM Blog");while($row = mysqli_fetch_array($query))
{
echo "<div class=\"blogsnippet\">";
echo "<h4>" . $row['Title'] . "</h4>" . $row['SubHeading'];
echo "</div>";
}}
3 回答
慕田峪4524236
TA贡献1875条经验 获得超5个赞
$con
getPosts
function getPosts(mysqli $con) { // etc
$con=mysqli_connect("localhost","xxxx","xxxx","xxxxx");if (mysqli_connect_errno()) { throw new Exception(mysqli_connect_error(), mysqli_connect_errno());}getPosts($con);
阿波罗的战车
TA贡献1862条经验 获得超6个赞
function getPosts() {global $con;$query = mysqli_query($con,"SELECT * FROM Blog");while($row = mysqli_fetch_array($query)) { echo "<div class=\"blogsnippet\">"; echo "<h4>" . $row['Title'] . "</h4>" . $row['SubHeading']; echo "</div>"; }}
qq_花开花谢_0
TA贡献1835条经验 获得超7个赞
getPosts()
$con
添加回答
举报
0/150
提交
取消