dgnzcn Posted September 3, 2012 Share Posted September 3, 2012 hello everybody. error_log file size is increasing to 2-3gb with following error message. how can i fix this errors: PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/test/public_html/solnav.php on line 76 solnav.php line 74 is : echo "Hata: ". mysql_error(); solnav.php line 75 is : } solnav.php line 76 is : $veri=mysql_fetch_array($sorgu); solnav.php line 77 is : if($veri['aitlik']!=-1) solnav.php line 76 is : $veri=mysql_fetch_array($sorgu); solnav.php file codes: <?php $baglan = mysql_connect("localhost","TEST","TEST"); mysql_select_db("TEST", $baglan); mysql_query("set names utf8"); //Herhangi bir linkin alt linkleri varmı diye kontrol eder function varmisinYokmusun($aitlik) { $select = "select * from menu_bilgi2 where aitlik = $aitlik ORDER BY sira asc"; $sorgu = mysql_query($select); $veri=mysql_fetch_array($sorgu); //Alt linkleri varsa true yoksa false değerini d?nd?r?yorum if($veri) return true; else return false; } /*$aitliğin varsayılan değerini -1 yapıyoruz. Bu sayede ana başlıklar g?r?necek. Veri tabanında da ana başlıkların aitliklerini -1 olarak atamıştık*/ function menuGetir($aitlik = -1,&$menuler) { $select = "select * from menu_bilgi2 where aitlik = $aitlik order by sira ASC"; $sorgu = mysql_query($select); if(!$sorgu) { echo "Hata: ". mysql_error(); } while(($veri=mysql_fetch_array($sorgu))) { if($veri['urun_mu']==1) { //urun_id sini $veri['link'] ile değil $veri['id'] ile karşılaştırmalıyız. Aksi taktider ?r?n bulunmaz. $select2 = "select * from urunler where urun_id ='".$veri['id']."'"; $sorgu2 = mysql_query($select2); $veri2=mysql_fetch_array($sorgu2); // bu satırda linki hangi sayfaya verdiysen yolBul() fonksiyonunu da o sayafada kullanmalısın. //Ben yine bulunduğum sayfaya(index.php) y?nlendirdiğim i?in fonksiyonu bu sayfada ?ağırdım. $menuler .= "<li><a href='index.php?gogo=urunGetir&urun_id=".$veri2['urun_id']."'>".$veri['menu_adi']."</a>\n"; } else { $menuler .= "<li><a href='".$veri['link']."'>".$veri['menu_adi']."</a>\n"; } if(varmisinYokmusun($veri['id'])) { //Varım diyor $menuler .= "<ul>\n"; menuGetir($veri['id'],$menuler); $menuler .= "</ul>\n</li>\n"; } else { //Yokum diyorrrrrrrrrrr $menuler .= "</li>\n"; } } } //YOL BULLLLLLLLLLLLLLLLLLLL function yolBul($id,&$konum) { $select = "select * from menu_bilgi2 where id =".$id; $sorgu = mysql_query($select); if(!$sorgu) { echo "Hata: ". mysql_error(); } $veri=mysql_fetch_array($sorgu); if($veri['aitlik']!=-1) { //Eğer aitlik -1 değilse herhangi bir linkin alt linki demektir. //Bu y?zden ait olduğu linkin id sini (aitlik) fonksiyona g?ndererek //Onunda ait olduğu linki buluyorum $menu_bilgi = array("id"=>$veri["id"],"ad"=>$veri['menu_adi']); array_push($konum,$menu_bilgi); yolBul($veri['aitlik'],$konum); } else { $menu_bilgi = array("id"=>$veri["id"],"ad"=>$veri['menu_adi']); array_push($konum,$menu_bilgi); } } //YOL BULLLLLLLLLLLLLLLLLLL SONUUUUUU ?> Quote Link to comment https://forums.phpfreaks.com/topic/267939-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-home/ Share on other sites More sharing options...
jcbones Posted September 3, 2012 Share Posted September 3, 2012 Fix the database query. The resource is being returned as a boolean. The only time mysql_query returns a boolean is if it is false, which means it failed, which means there is an error associated with it. Surely you have seen this same thread topic before, there is usually 1 per day. Quote Link to comment https://forums.phpfreaks.com/topic/267939-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-home/#findComment-1374858 Share on other sites More sharing options...
PFMaBiSmAd Posted September 3, 2012 Share Posted September 3, 2012 You have some error checking logic in your code to test if some of the queries execute with or without an error, but you are not preventing the remainder of the relevant code from running when there is a query error, so you get follow-on errors. You need to troubleshoot why the query is failing (your echo "Hata: ". mysql_error(); statement would be outputting a mysql error message) and you need to add an else{} condition to your error checking logic to prevent the code from using the non-existent result from a query when the query fails edit: or use return false; in the error checking logic so that the code returns from the function call and does not continue running past that point. Quote Link to comment https://forums.phpfreaks.com/topic/267939-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-home/#findComment-1374881 Share on other sites More sharing options...
dgnzcn Posted September 4, 2012 Author Share Posted September 4, 2012 thanks PFMaBiSmAd i add the return false; then it is solved. Quote Link to comment https://forums.phpfreaks.com/topic/267939-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-home/#findComment-1375103 Share on other sites More sharing options...
PFMaBiSmAd Posted September 4, 2012 Share Posted September 4, 2012 I'll assume that means that you also found and fixed what ever was causing the query to fail in the first place... Quote Link to comment https://forums.phpfreaks.com/topic/267939-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-in-home/#findComment-1375111 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.