• 06-08-2013, 13:16:12
    #1
    arkadaşlar merhaba,

    yeni bi scriptle bi haber sitesi açtımda. Ufak bi kaç hata var. Şuan beni rahatsız eden anketler bölümünün üstünde çıkan

    Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/siteismi/public_html/poll_quary/top.php on line 62
    
    Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/siteismi/public_html/poll_quary/top.php on line 78
    
    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/siteismi/public_html/poll_quary/top.php on line 79
    bunu nasıl çözerim. sitenin linkini pm den verebilirim. Teşekkürler.
  • 06-08-2013, 13:18:12
    #2
    top.php kodlarını yazabilirmisiniz hocam.
  • 06-08-2013, 13:40:06
    #3
    Tayko adlı üyeden alıntı: mesajı görüntüle
    arkadaşlar merhaba,

    yeni bi scriptle bi haber sitesi açtımda. Ufak bi kaç hata var. Şuan beni rahatsız eden anketler bölümünün üstünde çıkan
    ....

    bunu nasıl çözerim. sitenin linkini pm den verebilirim. Teşekkürler.
    sql kodunda hata var..
    kodu yazarsanız yardımcı olabiilriz
  • 06-08-2013, 13:49:55
    #4
    hata değil uyarı veriyor. mysql sorgularında birşeyler yanlış. bu uyarıların gözüktüğü sayfanın en üstüne error_reporting(0); yazarsanız bu uyarılar gözükmez.
  • 06-08-2013, 13:58:35
    #5
    Kimlik doğrulama veya yönetimden onay bekliyor.
    top.php 62, 78 ve 79. satırlardan önce gelen mysql_query sorgusunu inceleyin. SQL de olmayan bir veriyi çekip kontrolsüz işlemiş o nedenle hata veriyor, ya if ile bir kontrol eklersiniz yada veritabanına o çekmeye çalıştığı bilgiyi elle girersiniz düzelir.
  • 06-08-2013, 14:02:29
    #6
    <?php
    
    include ("config.php");
    
    if (isset ($_REQUEST['poll'])) {
    
    	$result = mysql_query ("SELECT pollid, title, starts, expires, vote, voting, results, graph, resultsvotes, ip, cookies FROM polls WHERE status='on' AND pollid='$_REQUEST[poll]'");
    	
    } else {
    
    	$result = mysql_query ("SELECT pollid, title, starts, expires, vote, voting, results, graph, resultsvotes, ip, cookies FROM polls WHERE status='on' ORDER BY pollid DESC LIMIT 1");
    	
    }
    
    $totalpolls = mysql_num_rows ($result);
    
    if ($totalpolls > 0) {
    
    	$polls = mysql_fetch_array ($result);
    	
    	$whatpoll = $polls['pollid'];
    	$title = $polls['title'];
    	
    	// Calculate Poll Expiration
    	list ($dayx, $monthx, $yearx) = explode ("/", $polls['expires']);
    	$now = mktime (0, 0, 0, date ("m"), date ("d"), date ("Y"));
    	$expire = mktime (0, 0, 0, $monthx, $dayx, $yearx);
    	
    	if ($expire <= $now) {
    	
    		$expired = "yes";
    		
    	} else {
    	
    		$expired = "no";
    		
    	}
    	
    	// Calculate Poll Start
    	if ($expired == "no") {
    	
    		list ($days, $months, $years) = explode ("/", $polls['starts']);
    		$starts = mktime (0, 0, 0, $months, $days, $years);
    	
    		if ($starts > $now) {
    	
    			$started = "no";
    		
    		} else {
    	
    			$started = "yes";
    		
    		}
    		
    	} else {
    	
    		$started = "no";
    	
    	}
    	
    	// Check if IP is blocked from voting
    	$blockcheck = mysql_num_rows (mysql_query ("SELECT blockedid FROM blocked WHERE (polls LIKE '%$polls[title]%' OR polls LIKE '%all%') AND ip='$_SERVER[REMOTE_ADDR]'"));
    	
    	if ($blockcheck == 0) {
    	
    		$blocked = "no";
    		
    	} else {
    	
    		$blocked = "yes";
    		
    	}
    	
    	// Check if user has voted (IP)
    	if ($polls['ip'] == "yes") {
    	
    		$check = mysql_query ("SELECT ipid, vote FROM ip WHERE title='$polls[title]' AND ip='$_SERVER[REMOTE_ADDR]'");
    		$checkip = mysql_num_rows ($check);
    		$ip = mysql_fetch_array ($check);
    		
    		if ($checkip == 0 | $ip['vote'] < time ()) {
    		
    			$voteip = "yes";
    			
    		} else {
    		
    			$voteip = "no";
    			
    		}
    		
    		if ($ip['vote'] <= time ()) {
    		
    			mysql_query ("DELETE FROM ip WHERE title='$polls[title]' AND ip='$_SERVER[REMOTE_ADDR]'");
    			
    		}
    		
    	} else {
    	
    		$voteip = "none";
    		
    	}
    	
    	// Check if user has voted (Cookie)
    	if ($polls['cookies'] == "yes") {
    		
    		if (isset ($_COOKIE[$whatpoll])) {
    		
    			if ($_COOKIE[$whatpoll] == $title) {
    		
    				$votecookies = "no";
    				
    			} else {
    			
    				$votecookies = "yes";
    			
    			}
    			
    		} else {
    		
    			$votecookies = "yes";
    			
    		}
    		
    	} else {
    	
    		$votecookies = "none";
    		
    	} 
    	
    	if (isset ($_POST['stage'])) {
    
    		$polls = mysql_fetch_array (mysql_query ("SELECT title, vote, ip, cookies FROM polls WHERE status='on' AND pollid='$_POST[poll]'"));
    		$options = mysql_fetch_array (mysql_query ("SELECT optionid, options, votes FROM options WHERE pollid='$_POST[poll]' AND optionid='$_POST[option]'"));
    		
    		$title = $polls['title'];
    		
    		$nextvote = $polls['vote'] + time ();
    		$votes = $options['votes'] + 1;
    		
    		if ($polls['ip'] == "yes" && $voteip != 'no') {
    		
    			$ip = mysql_fetch_array (mysql_query ("SELECT ipid FROM ip ORDER BY ipid DESC"));
    			
    			$ipid = $ip['ipid'] + 1;
    		
    			mysql_query ("INSERT INTO ip (ipid, title, ip, vote) VALUES ('$ipid', '$polls[title]', '$_SERVER[REMOTE_ADDR]', '$nextvote')");
    			
    		}
    		
    		if ($polls['cookies'] == "yes" && $votecookies != 'no') {
    		
    			
    		}
    		
    		if ($votecookies != 'no' && $voteip != 'no' && $blocked != 'yes' && $started == 'yes' && $expired == 'no') {
    		
    			mysql_query ("UPDATE options SET votes='$votes' WHERE optionid='$options[optionid]'");
    			
    		}
    				
    	}
    	
    }
    	
    ?>
    top.php kodları
  • 06-08-2013, 14:45:12
    #7
    <?php 
    
    include ("config.php"); 
    
    if (isset ($_REQUEST['poll'])) { 
    
        $result = mysql_query ("SELECT pollid, title, starts, expires, vote, voting, results, graph, resultsvotes, ip, cookies FROM polls WHERE status='on' AND pollid='$_REQUEST[poll]'"); 
         
    } else { 
    
        $result = mysql_query ("SELECT pollid, title, starts, expires, vote, voting, results, graph, resultsvotes, ip, cookies FROM polls WHERE status='on' ORDER BY pollid DESC LIMIT 1"); 
         
    } 
    
    $totalpolls = mysql_num_rows ($result); 
    
    if ($totalpolls > 0) { 
    
        $polls = mysql_fetch_array ($result); 
         
        $whatpoll = $polls['pollid']; 
        $title = $polls['title']; 
         
        // Calculate Poll Expiration 
        list ($dayx, $monthx, $yearx) = explode ("/", $polls['expires']); 
        $now = mktime (0, 0, 0, date ("m"), date ("d"), date ("Y")); 
        $expire = mktime (0, 0, 0, $monthx, $dayx, $yearx); 
         
        if ($expire <= $now) { 
         
            $expired = "yes"; 
             
        } else { 
         
            $expired = "no"; 
             
        } 
         
        // Calculate Poll Start 
        if ($expired == "no") { 
         
            list ($days, $months, $years) = explode ("/", $polls['starts']); 
            $starts = mktime (0, 0, 0, $months, $days, $years); 
         
            if ($starts > $now) { 
         
                $started = "no"; 
             
            } else { 
         
                $started = "yes"; 
             
            } 
             
        } else { 
         
            $started = "no"; 
         
        } 
         
        // Check if IP is blocked from voting 
    	$blockcheck = mysql_query ("SELECT blockedid FROM blocked WHERE (polls LIKE '%$polls[title]%' OR polls LIKE '%all%') AND ip='$_SERVER[REMOTE_ADDR]'")
    
        if (mysql_num_rows($blockcheck) > 0) { 
         
            $blocked = "yes"; 
             
        } else { 
         
            $blocked = "no"; 
             
        } 
         
        // Check if user has voted (IP) 
        if ($polls['ip'] == "yes") { 
         
            $check = mysql_query ("SELECT ipid, vote FROM ip WHERE title='$polls[title]' AND ip='$_SERVER[REMOTE_ADDR]'"); 
             
            if(mysql_num_rows($check) > 0){
    			$ip = mysql_fetch_array ($check);
    			if ($ip['vote'] < time ()) { 
    				$voteip = "yes"; 
    			} else { 
    				$voteip = "no"; 
    			} 
    			if ($ip['vote'] <= time ()) { 
             
    				mysql_query ("DELETE FROM ip WHERE title='$polls[title]' AND ip='$_SERVER[REMOTE_ADDR]'"); 
    				 
    			} 
    		}
    		
             
        } else { 
         
            $voteip = "none"; 
             
        } 
         
        // Check if user has voted (Cookie) 
        if ($polls['cookies'] == "yes") { 
             
            if (isset ($_COOKIE[$whatpoll])) { 
             
                if ($_COOKIE[$whatpoll] == $title) { 
             
                    $votecookies = "no"; 
                     
                } else { 
                 
                    $votecookies = "yes"; 
                 
                } 
                 
            } else { 
             
                $votecookies = "yes"; 
                 
            } 
             
        } else { 
         
            $votecookies = "none"; 
             
        }  
         
        if (isset ($_POST['stage'])) { 
    
            $polls = mysql_fetch_array (mysql_query ("SELECT title, vote, ip, cookies FROM polls WHERE status='on' AND pollid='$_POST[poll]'")); 
            $options = mysql_fetch_array (mysql_query ("SELECT optionid, options, votes FROM options WHERE pollid='$_POST[poll]' AND optionid='$_POST[option]'")); 
             
            $title = $polls['title']; 
             
            $nextvote = $polls['vote'] + time (); 
            $votes = $options['votes'] + 1; 
             
            if ($polls['ip'] == "yes" && $voteip != 'no') { 
             
                $ip = mysql_fetch_array (mysql_query ("SELECT ipid FROM ip ORDER BY ipid DESC")); 
                 
                $ipid = $ip['ipid'] + 1; 
             
                mysql_query ("INSERT INTO ip (ipid, title, ip, vote) VALUES ('$ipid', '$polls[title]', '$_SERVER[REMOTE_ADDR]', '$nextvote')"); 
                 
            } 
             
            if ($polls['cookies'] == "yes" && $votecookies != 'no') { 
             
                 
            } 
             
            if ($votecookies != 'no' && $voteip != 'no' && $blocked != 'yes' && $started == 'yes' && $expired == 'no') { 
             
                mysql_query ("UPDATE options SET votes='$votes' WHERE optionid='$options[optionid]'"); 
                 
            } 
                     
        } 
         
    } 
         
    ?>
  • 06-08-2013, 17:09:17
    #8
    Üyeliği durduruldu
    $result = mysql_query ("SELECT pollid, title, starts, expires, vote, voting, results, graph, resultsvotes, ip, cookies FROM polls WHERE status='on' AND pollid='$_REQUEST[poll]'");


    $result = mysql_query ("SELECT pollid, title, starts, expires, vote, voting, results, graph, resultsvotes, ip, cookies FROM polls WHERE status='on' ORDER BY pollid DESC LIMIT 1");


    sorgularında hata var bu sorgular doğru düzgün çalışmamış... sorgudaki sütunlarla db deki sütunları karşılaştır.
  • 06-08-2013, 20:21:54
    #9
    Yukarıdaki hata mesajları sorgularda hata olduğu anlamına gelmiyor. Sorgular doğru olabilir ancak veritabanında herhangi bir veri olmaması durumunda da bu hataları alırsınız. Hiç bir verisi olmayan tablodan dönen sonucu fetch etmeye kalkarsanız, hoooop der size yukarıda görüldüğü gibi.

    madly0011 adlı üyeden alıntı: mesajı görüntüle
    $result = mysql_query ("SELECT pollid, title, starts, expires, vote, voting, results, graph, resultsvotes, ip, cookies FROM polls WHERE status='on' AND pollid='$_REQUEST[poll]'");


    $result = mysql_query ("SELECT pollid, title, starts, expires, vote, voting, results, graph, resultsvotes, ip, cookies FROM polls WHERE status='on' ORDER BY pollid DESC LIMIT 1");


    sorgularında hata var bu sorgular doğru düzgün çalışmamış... sorgudaki sütunlarla db deki sütunları karşılaştır.