php mysqli query expects parameter 1 be to string

前端 未结 2 1403
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-27 16:43

I was coding a User database which calls an static method of find_all which calls an query method which in turn returns all the value of a database but i am finding trouble in d

2条回答
  •  渐次进展
    2021-01-27 17:12

    When using mysqli in a procedural style, the first argument to mysqli_query must be a connection object

    From the official documentation:

    mixed mysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT ] )
    

    So you need to change the order of the arguments, $this->connection goes first and $sql goes second:

    $result = mysqli_query($this->connection, $sql);
    

提交回复
热议问题