php mysqli query expects parameter 1 be to string

前端 未结 2 1352
爱一瞬间的悲伤
爱一瞬间的悲伤 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:08

    Just read docs:
    mixed

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

    You must change your arguments to

    mysqli_query($this->connection, $sql)

    0 讨论(0)
  • 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);
    
    0 讨论(0)
提交回复
热议问题