php mysql错误:警告:mysqli_error()预计正好有1个参数,给出0

时间:2013-05-06 06:37:46

标签: php mysqli

我想使用文件的description属性显示数据库中的项目。例如,我上传了3个文件,除了主键外,它们自动具有相同的信息。

if($type=="Title"){
$key = $_POST['search_key'];
    if($key!=null){ 
        $result = mysqli_query($con,"SELECT DISTINCT description  FROM __scannedfiles WHERE title='$key' AND  deptname='$dept_name'")  OR die(mysqli_error());
    $count =mysqli_num_rows($result);
    if($count==0){
       echo '<script type="text/javascript"> window.onload = function(){alert("File not found!")} </script>';
    } else if($count>0) {
        echo'<div class="searched_items_pane">
       <table class="table" width="100%" style="table-layout:fixed">
         <col width="20%">
        <tr>
        <td> </td>
        <th>  Title </th> 
        <th> Type </th>
        <th> Date </th>
        <th>  Description </th>
        </tr>';
    while($row = mysqli_fetch_array($result)){
      echo'<tr>
        <td><a href="items.php?     desc='.urlencode($row[7]).'"onClick="MM_openBrWindow(\'items.php?desc='.urlencode($row[7]).'\',\'google\',\'width=650,height=500\'); return false;">
        <img src="Folder-Blank-icon.png"></a></td>          


 <td> '.$row[1].' </td>
        <td> '.$row[5].' </td>
        <td> '.$row[6].' </td>
        <td> '.$row[7].' </td>
         </tr>';
    }
    if($count>0){
      echo'</table> 
      </div>';
    }
}                               
}
  }
mysqli_close($con);     
 }

结果:

     karla   Memo    2012-12-31  2131
     karla   Policy  2013-12-31  121212
     karla   Memo    2013-12-31  qweqw
     karla   Memo    2013-12-31  qweqw

这是期望的结果:

     karla   Memo    2012-12-31  2131
     karla   Policy  2013-12-31  121212
     karla   Memo    2013-12-31  qweqw

1 个答案:

答案 0 :(得分:2)

mysqli_error()需要连接对象作为参数

mysqli_error($con);