v2.5.2
Giriş yap

Fatal error: Uncaught Error: Call to a member function rowCount() on boolean hatası

xahmetkilic
1,186 defa görüntülendi

başlıkta yazdığım gibi bir hata alıyorum localde bir sorun olmuyor. Sunucuya yükleyince böyle bir hata alıyorum.
Hatayı aldığım kod kısmını alta bırakıyorum.

<?php
   $vList = $db->query("SELECT * FROM news where news_category='30'", PDO::FETCH_ASSOC);
    if($vList->rowCount()){
	    foreach ($vList as $vkey => $List) {
		    $Dizi[] = $List["news_title"];
	    }
    }

?>
PHP
kargasa1982
1124 gün önce
<?php
   $vList = $db->query("SELECT * FROM news where news_category='30'", PDO::FETCH_ASSOC);
    if($vList->rowCount()){
	    foreach ($vList->fetchAll() as $vkey => $List) {
		    $Dizi[] = $List["news_title"];
	    }
    }

?>
PHP

döngüye soktuğun $vList sadece bir sorgu, üst satırda rowCount() ile satır sayısını almışsın ama döngüye fetchAll() ile girmemişsin.