2012-05-02 11 views
0

Possible Duplicate:
Warning: mysql_fetch_* expects parameter 1 to be resource, boolean given errormysqli_num_rows()私はこのエラーが発生したパラメータ1が

をmysqli_resultことを期待しています。私が "ステータス"を提出すると、それは私のデータベースに保存されるので、その部分に何も問題はありません。

<?php 
    //Eerst bouwen we onze applicatie uit zodat ze werkt, ook zonder JavaScript 
    include_once("classes/Activity.class.php"); 
    $activity = new Activity(); 

    //controleer of er een update wordt verzonden 
    if(!empty($_POST['activitymessage'])) 
    { 
     $activity->Text = $_POST['activitymessage']; 
     try 
     { 
      $activity->Save(); 
     } 
     catch (Exception $e) 
     { 
      $feedback = $e->getMessage(); 
     } 
    } 

    //altijd alle laatste activiteiten ophalen 
    $recentActivities = $activity->GetRecentActivities(); 

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>IMDBook</title> 
<link href="css/reset.css" rel="stylesheet" /> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 
<style type="text/css"> 
body 
{ 
    font-family: "Lucida Grande", Tahoma, Verdana, sans-serif; 
} 

h1 
{ 
    margin-bottom: 5px; 
} 

h2 
{ 
    color: #3b5998; 
    display: inline; 
} 

ul 
{ 
    margin-top: 10px; 
} 

ul li 
{ 
    border-bottom: 1px dotted #fff; 
    padding: 15px 5px; 
} 

#activitymessage 
{ 
    border: 1px solid #bbbbbb; 
    padding: 5px; 
    width: 280px; 
    font-size: 1.1em; 
} 

div.statusupdates 
{ 
    width: 380px; 
    background-color: #ccc; 
    padding: 20px; 
    margin: 0 auto; 
} 

#btnSubmit 
{ 
    background-color: #627aac; 
    color: #fff; 
    font-size: 1.1em; 
    border: 1px solid #29447e; 
} 

div.errors 
{ 
    width: 380px; 
    margin: 25px auto; 
    background-color: #bd273a; 
    -moz-border-radius: 10px; 
    color: white; 
    font-weight: bold; 
    text-shadow: 1px 1px 1px #000; 
    padding: 20px; 
    display:none; 
} 
</style> 
<script type="text/javascript"> 


</script> 
</head> 
<body> 
<div> 
    <div class="errors"></div> 

    <form method="post" action=""> 
     <div class="statusupdates"> 
     <h1>GoodBytes.be</h1> 
     <input type="text" value="What's on your mind?" id="activitymessage" name="activitymessage" /> 
     <input id="btnSubmit" type="submit" value="Share" /> 

     <ul id="listupdates"> 
     <?php 
      if(mysqli_num_rows($recentActivities) > 0) 
      {  
       while($singleActivity = mysqli_fetch_assoc($recentActivities)) 
       { 
        echo "<li><h2>GoodBytes.be</h2> ". $singleActivity['activity_description'] ."</li>"; 
       } 
      } 
      else 
      { 
       echo "<li>Waiting for first status update</li>";  
      } 
     ?> 
     </ul> 

     </div> 
    </form> 

</div> 
</body> 
</html> 
+0

'$ activity-> GetRecentActivities();'のコードは何ですか?それは本当に 'mysql_query()'の結果ですか? – adrien

+0

次回は問題に不可欠ではない部分のコードを削除してください! – Sirko

答えて

1

あなたはそうのようなチェックを行う必要があります:クエリが失敗した

if($recentActivities !== false) { 
    //code here 
} 

場合は、データベースの呼び出しはfalseを返します。

関連する問題