public function Extragere_tabel()
{
if($this->cuvant_cautat)
{
$cuvv=$this->cuvant_cautat;
$this->cuvant_cautat = $this->bd->query("SELECT cuvant_stimul, cuvant_raspuns, aparitii FROM dc_asociatii WHERE cuvant_stimul='".$this->bd->real_escape_string(trim($this->cuvant_cautat))."' OR cuvant_raspuns='".$this->bd->real_escape_string(trim($this->cuvant_cautat))."' ORDER BY aparitii DESC");
echo "<br /><center><table border=1 width=500>
<tr><td><strong>Слово – стимул</strong></td><td><strong>Слово – реакция</strong></td><td><strong>Kоличество</strong></td></tr>";
while($cuvintele = $this->cuvant_cautat->fetch_array(MYSQLI_NUM))
{
if($this->bd->real_escape_string(trim($this->cuvant_cautat)) == $cuvintele[0])
echo "<tr><td>$cuvintele[0]</td><td>$cuvintele[1]</td><td>$cuvintele[2]</td></tr>";
elseif($this->bd->real_escape_string(trim($this->cuvant_cautat)) == $cuvintele[1])
echo "<tr><td>$cuvintele[1]</td><td>$cuvintele[0]</td><td>$cuvintele[2]</td></tr>";
}
echo "</table></center>";
}
}
警告:trim()期望参数1为字符串,对象在 第94行的C:\ xampp \ htdocs \ motor \ classes \ user.Class.php
警告:trim()期望参数1为字符串,对象在 第96行的C:\ xampp \ htdocs \ motor \ classes \ user.Class.php
第94行如下:
if($this->bd->real_escape_string(trim($this->cuvant_cautat)) == $cuvintele[0])
第96行如下:
elseif($this->bd->real_escape_string(trim($this->cuvant_cautat)) == $cuvintele[1])
答案 0 :(得分:0)
我这样解决了:
public function Extragere_tabel()
{
if($this->cuvant_cautat)
{
$cuvv=$this->cuvant_cautat;
$this->cuvant_cautat = $this->bd->query("SELECT cuvant_stimul, cuvant_raspuns, aparitii FROM dc_asociatii WHERE cuvant_stimul='".$this->bd->real_escape_string(trim($this->cuvant_cautat))."' OR cuvant_raspuns='".$this->bd->real_escape_string(trim($this->cuvant_cautat))."' ORDER BY aparitii DESC");
echo "<br /><center><table border=1 width=500>
<tr><td><strong>Слово – стимул</strong></td><td><strong>Слово – реакция</strong></td><td><strong>Kоличество</strong></td></tr>";
while($cuvintele = $this->cuvant_cautat->fetch_array(MYSQLI_NUM))
{
if($cuvv == $cuvintele[0])
echo "<tr><td>$cuvintele[0]</td><td>$cuvintele[1]</td><td>$cuvintele[2]</td></tr>";
else if($cuvv == $cuvintele[1])
echo "<tr><td>$cuvintele[1]</td><td>$cuvintele[0]</td><td>$cuvintele[2]</td></tr>";
}
echo "</table></center>";
}
}
谢谢!