Jump to content

mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/.


dgnzcn

Recommended Posts

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
?>

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.