mysqli_prepare() expects parameter 1 to be mysqli

前端 未结 3 1265
一个人的身影
一个人的身影 2021-01-28 05:15

Having trouble with procedural use of mysqli

Here\'s the function:

db.php



        
3条回答
  •  灰色年华
    2021-01-28 06:14

    The way the two files db.php and function.php are glued together I think results in $link being defined as a global variable - you need to use global to access it within function:

    function addItemToCatalog($var1, $var2, $var3, $var4) {
        global $link;
        ...
    }
    

    or give the $link to the function explicitly through parameter:

    function addItemToCatalog($var1, $var2, $var3, $var4, $link) {
        ...
    }
    

提交回复
热议问题