gpt4 book ai didi

php - mysqli_connect 不会传递给它函数

转载 作者:行者123 更新时间:2023-12-02 05:17:32 24 4
gpt4 key购买 nike

<分区>

我正在将旧的 mysql 转换为 mysqli 并遇到一个问题,即我的 mysqli_connect 在我的任何函数中都不起作用。在互联网上查看后,我发现这是一个范围问题,所以我将 mysqli_connect 变量传递给函数。这没有用。这是我的两个错误

Notice: Undefined variable: con in C:\xampp\htdocs\bear_mysqli\functions\cart.php on line 44

Warning: Missing argument 1 for products(), called in C:\xampp\htdocs\bear_mysqli\shop.php on line 30 and defined in C:\xampp\htdocs\bear_mysqli\functions\cart.php on line 40

$con = mysqli_connect("localhost","root","","bear") or die ($connect_error);

function products($con)
{
$get = mysqli_query($con,'SELECT * FROM items WHERE quantity > 0 ORDER BY id DESC ');
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com