致命错误:在资源上调用成员函数mysql查询

时间:2016-10-31 08:11:50

标签: php

我需要帮助,因为我收到了一条错误消息,例如“调用资源上的成员函数mysql查询”

这是我的代码:

<?php
include "koneksi.php";
$id_data = $_GET['id_data'];
ignore_user_abort(true);
set_time_limit(0); // disable the time limit for this script
 

$query = "SELECT * FROM kinerja WHERE id_data = $id_data";
$hasil_data = $koneksi->query($query);

if ($hasil_data->num_rows > 0) {
    // output data of each row
    while($row = $hasil_data->mysql_fetch_assoc()) {
      $filename = $row['nama_file'];
  }
}

$path = "../admin/files/"; // change the path to fit your websites document structure
 
//$dl_file = preg_replace("([^\w\s\d\-_~,;:\[\]\(\).]|[\.]{2,})", '', $_GET['download_file']); // simple file name validation
//$dl_file = filter_var($dl_file, FILTER_SANITIZE_URL); // Remove (more) invalid characters
$fullPath = $path.$filename;
 
if ($fd = fopen ($fullPath, "r")) {
    $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);
    switch ($ext) {
        case "pdf":
        header("Content-type: application/pdf");
        header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a file download
        break;
        // add more headers for other content types here
        default;
        header("Content-type: application/octet-stream");
        header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
        break;
    }
    header("Content-length: $fsize");
    header("Cache-control: private"); //use this to open files directly
    while(!feof($fd)) {
        $buffer = fread($fd, 2048);
        echo $buffer;
    }
}
fclose ($fd);
exit;

?>

我需要这个代码的帮助,我真的很赞赏任何帮助。抱歉我的英语不好。

1 个答案:

答案 0 :(得分:0)

看起来错误在koneksi.php中。我猜它在该类中的函数query()附近。如果包含该类,则更容易发现错误。