我想使用PDO加入,但是有错误。我研究其他问题,但我不明白:(我的查询和错误是;
错误
PHP致命错误:在第72行的/ssd4/muhtesemciftlik/public_html/referans.php中调用非对象的成员函数rowCount()
我的查询
<?php
$id=2
$query = $db->query("SELECT ref_urun,ref_tl FROM degerler INNER JOIN kullanicilar ON kullanicilar.ref = degerler.kullanici WHERE kullanicilar.ref = {'$id'}", PDO::FETCH_ASSOC);
if ( $query->rowCount() ) { //kayıt varsa
foreach( $query as $row ){
echo "
<tr>
<th style=\"width: 10px\">#</th>
<th>".$row["kullanici"]."</th>
<th>".$row["ref_urun"]."</th>
<th>".$row["ref_tl"]."</th>
</tr>
";
}
}
?>
答案 0 :(得分:0)
变化:
$query = $db->query("SELECT ref_urun,ref_tl FROM degerler INNER JOIN kullanicilar ON kullanicilar.ref = degerler.kullanici WHERE kullanicilar.ref = {'$id'}", PDO::FETCH_ASSOC);
要:
$query = $db->query("SELECT ref_urun,ref_tl FROM degerler INNER JOIN kullanicilar ON kullanicilar.ref = degerler.kullanici WHERE kullanicilar.ref = '{$id}'", PDO::FETCH_ASSOC);