在数组上调用成员函数fetch_array()

时间:2015-04-18 18:01:13

标签: php mysql ajax class

    if($this->cuvant_cautat)
    {
        $this->cuvant_cautat = $this->bd->query("SELECT cuvant_raspuns FROM dc_asociatii WHERE cuvant_stimul='".$this->cuvant_cautat."' ORDER BY id DESC LIMIT 0, 5");
        //echo $this->cuvant_cautat[0];
        while($this->cuvant_cautat = $this->cuvant_cautat->fetch_array(MYSQLI_NUM))
            {
                echo $this->cuvant_cautat[0];
            }
    }
  

致命错误:在数组中调用成员函数fetch_array()   第89行的C:\ xampp \ htdocs \ motor \ classes \ user.Class.php

第89行如下:

while($this->cuvant_cautat = $this->cuvant_cautat->fetch_array(MYSQLI_NUM))

1 个答案:

答案 0 :(得分:2)

您每次都会覆盖$this->cuvant_cautat。在迭代中使用不同的变量。

while ($something_else = $this->cuvant_cautat->fetch_array(MYSQLI_NUM))) {
    echo $something_else[0];
}