2013-10-14 144 views
1

给予这是我的网页警告:mysql_fetch_array()预计参数1是资源,布尔在错误

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<?php 
require("admin/config/connect.php"); 

?> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<META http-equiv=content-type content=text/html;charset=iso-8859-9> 
<META http-equiv=content-type content=text/html;charset=windows-1254> 
<META http-equiv=content-type content=text/html;charset=x-mac-turkish> 
<meta name="keywords" content="" /> 
<meta name="description" content="" /> 
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>Lettering by FCT</title> 
<link href="http://fonts.googleapis.com/css?family=Arvo" rel="stylesheet" type="text/css" /> 
<link href="style.css" rel="stylesheet" type="text/css" media="screen" /> 
</head> 
<body> 
<div id="wrapper"> 
    <div id="page"> 
     <div id="page-bgtop"> 
      <div id="page-bgbtm"> 
       <div id="content"> 
        <div class="post"> 
        <?php $id = $_REQUEST["id"]; 
        $sorgu=mysql_query("select * from portalmakale where id='$id'"); 

$oku=mysql_fetch_assoc($sorgu); 

        ?> 
         <h2 class="title"><?php echo $oku['baslk']; ?></h2> 
         <p class="meta"><?php echo $oku['tarih']; ?></p> 
         <div style="clear: both;"></div> 
         <div class="entry"> 
          <p><?php echo $oku['icerk']; ?></p> 
          <p class="links"><a href="#">&nbsp;&nbsp;&nbsp;</a></p> 
         </div> 
        </div> 
        <div class="post"> 
        <?php session_start(); 


    $sayi1 = rand(1,100); 
    $sayi2 = rand(1,600); 



    $toplam_sayi = $sayi1+$sayi2; 


    $_SESSION['guvenlik_kodu'] = "$toplam_sayi"; 


    ?> 
        <center><p><font size="+2">Yorum Yapın! </font></p> 
        <p><font size="2">&quot;Amaaan yorum yapsam nolur yapmasam nolur :S Ne işime yarıcak </font>&quot; demeden yorumlarınızın değerli olduğunu hatırlatalım .</p> 
        <center> <form id="form1" method="post" action="yorumekle.php?id=<?php echo $id ?>"> 
         <table width="404" height="155" border="0"> 

    <tr> 
    <th width="67" scope="row">Ad</th> 
    <td width="117"><center><input name="ad" type="text" /></center></td> 
    </tr> 
    <tr> 
    <th scope="row">Email</th> 
    <td><center><input name="email" type="text" /></center></td> 
    </tr> 
    <tr> 
    <th scope="row">Mesaj</th> 
    <td><center><textarea name="mesaj" rows="7" cols="30"></textarea></center></td> 
    </tr> 
    <tr> 
    <th scope="row">Doğrulama</th> 
    <td><center><input name="dorulama" type="text" /></center></td> 
    </tr> 
    <tr> 
    <th scope="row">G&ouml;nder</th> 
    <td><center><input name="" type="submit" value="Gönder" /></center></td> 
    </tr> 
</table> 
        </form></center> 
         <p>Sizin İçin Hiçbir Masraftan Kaçınmayıp, Yemeden i&ccedil;menden, G&uuml;nlerce oturup yazdığımız ve &ccedil;alışıp didinip emektar annelercesine uğraşıp oluşturduğumuz doğrulama kodunuz .</p> 
         <p><font size="+1"><?php echo'Güvenlik kodu: '; echo $sayi1+$sayi2 ?></font></p> 

        </center> 
        <div class="entry"> 
         <p><center>Css Ve Php bilgilerimizin el verdiğince yayınlayabildiğimiz yapılan yorumlar </center>.<center> 
         <?php 


//kaç tane gösterileceğini girin 
$gosterim=5; 
//gösterilecek sayfa numarasını alma 
[email protected]$_GET['sayfa']; 
//sayfa numarası kontrolü 
if(empty($sayfa) || !is_numeric($sayfa)){$sayfa=1;} 

//toplam kayıt sayısını alma 
$k_sayisi=mysql_num_rows(mysql_query("Select yorumid From yorum")); 
//kaç sayfa olacağını bulma 
$s_sayisi=ceil($k_sayisi/$gosterim); 
//hangi kayıttan itibaren gösterileceğini bulma 
$ilk_kayit=($sayfa*$gosterim)-$gosterim; 
?> 
         <?php $veri = mysql_query('select ad,mesaj from yorum where id=$id'); 

        ?> 
         <table width="522" border="1"> 
    <tr> 
    <th scope="col">Ad</th> 
    <th scope="col">Mesaj</th> 
    </tr> 
    <?php while($row = mysql_fetch_array($veri)){?> 
    <tr> 
    <td><?php echo $row['ad'];?></td> 
    <td><?php echo $row['mesaj'];?></td> 
    </tr> <?php } ?> 
</table><center> 
</p> <?php 



//ilk sayfaya gitme bağlantısı 
if($sayfa!=1){ 
    echo "<a href='?id=&sayfa=1'>İlk</a>"; 
    echo " "; 
} 
//diğer sayfalara geçiş bağlantısı koyma 
for($i=1;$i<=$s_sayisi;$i++){ 
    echo "<a href='?id=$id&sayfa={$i}'>$i</a>"; 
    echo " "; 
} 
//en son sayfaya gitme bağlantısı 
if($sayfa!=$s_sayisi){ 
    echo "<a href='?id=$id&sayfa={$s_sayisi}'>Son</a>"; 
} 

?> 
        </div> 
        </div> 
       </div> 
       <!-- end #content --> 
       <div id="sidebar"> 
        <div id="logo"> 
         <h1><a href="index.php">MybbEklenti</a></h1> 
         <p>slogans<a href="http://www.freecsstemplates.org/" rel="nofollow"></a></p> 
        </div> 
        <div id="menu"> 
         <ul> 
          <li class="current_page_item"><a href="#">Portal</a></li> 
          <li></li> 
          <li></li> 
          <li><a href="#">Hakkımızda</a></li> 
          <li></li> 
          <li><a href="#">İletişim</a></li> 
         </ul> 
        </div> 
        <ul> 
         <li> 
          <h2>Duyurular</h2> 
          <p>Mauris vitae nisl nec metus placerat perdiet est. Phasellus dapibus semper consectetuer hendrerit.</p> 

         </li> 
         <li> 
          <h2>Kategoriler</h2> 
          <ul> 
           <li><a href="#">Aliquam libero</a></li> 
           <li><a href="#">Consectetuer adipiscing elit</a></li> 
           <li><a href="#">Metus aliquam pellentesque</a></li> 
           <li><a href="#">Suspendisse iaculis mauris</a></li> 
           <li><a href="#">Urnanet non molestie semper</a></li> 
           <li><a href="#">Proin gravida orci porttitor</a></li> 
          </ul> 
         </li> 
         <li></li> 
         <li>      </li> 
        </ul> 
       </div> 
       <!-- end #sidebar --> 
       <div style="clear: both;">&nbsp;</div> 
      </div> 
     </div> 
    </div> 
    <!-- end #page --> 
</div> 
<div id="footer"> 
    <p>T&uuml;m Hakları Saklıdır !</p> 
</div> 
<!-- end #footer --> 
</body> 
</html> 

我的错误警告:mysql_fetch_array()预计参数1是资源,布尔在C中给出: \ wamp \ www \ lettering \ makale.php 113行。我该如何解决这个问题。 113行是;

<?php while($row = mysql_fetch_array($veri)){?> 

©尝试尽一切办法解决,但我仍然得到这个错误,这是错误的形象;

http://www.yukleresim.com/images/2013/10/14/Screenshot1.png

回答

0

替换 $veri = mysql_query("select ad,mesaj from yorum where id=$id")。每

Variable parsing为:http://php.net/manual/en/language.types.string.php

When a string is specified in double quotes or with heredoc, variables are parsed within it. 

而且,你试试你mysql_*功能转换到PDOmysqli。最好,你可以使用过程风格mysqli,因为它几乎类似mysql_*

这里是和面向对象的列表程序mysqlihttp://www.php.net/manual/en/mysqli.summary.php

0

mysql_query(),因为错误的返回false。使用mysql_error()来检查发生了什么,不要忘记每个查询都可能失败。核实。

也想想换成PDO。这比弃用mysql_*好。

+0

什么是PDO?我怎样才能使用mysql_error() – mert

+0

@mert http://www.php.net/pdo和http://www.php.net/mysql_error –

1

复制和粘贴查询

select * from portalmakale where id='$id' 

直接在数据库中,它会告诉你的错误。

也可以使用mysql_error()这样的

$sorgu=mysql_query("select * from portalmakale where id='$id'") or mysql_error(); 
-1

这是因为你的sql查询是不正确的。 mysql_query当查询无效时返回false。您的查询语句看起来正确。检查您的变量$ id是否设置。

<?php 
    if(isset($_REQUEST['id'])) { 
    $id = $_REQUEST['id'];//if this variable is empty mysql_query returns false 
    } 
    //Now write your other stuffs 

建议的位升级从MySQL的的mysqliPDO

-1
$veri = mysql_query('select ad,mesaj from yorum where id=$id'); 

你们的这个查询为空,不取任何结果,我会建议

echo 'select ad,mesaj from yorum where id=$id'; 

检查每个查询后查看查询是否正确,并直接在数据库中执行回显查询以查看结果。

0

当查询返回空记录集此错误只会产生。

所以首先检查查询中的每个参数(如字段,表名和id)。如果所有这些都是正确的,那么e * 在mysql中执行您的查询 *。或使用php函数mysql_error这将显示确切的错误,你会得到解决方案。

相关问题