Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\Fileshare\download.php on line 10
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '` = 8' at line 1.
It is displaying "Invalid file ID." at the end of everything.
Here is my code.
<?php include('core/inc/init.inc.php'); if (isset($_GET['file_id'])) { $file_id = (int)$_GET['file_id']; $file = mysql_query("SELECT `file_name`, `file_expiry` FROM `files` WHERE file_id` = {$file_id}"); if (mysql_num_rows($file) != 1) { echo mysql_error(); echo 'Invalid file ID.'; } else { $row = mysql_fetch_assoc($file); if ($row['file_expiry'] < time()) { echo 'This file has expired.'; } else { $path = "core/files/{$row['file_name']}"; header('Content-Type: application/octetstream'); header('Content-Type: application/octet-stream'); header('Content-Description: File Transfer'); header("Content-Disposition: attatchment; filename=\"{$row['file_name']}\""); header('Content-Length: ' . filesize($path)); readfile($path); } } } ?>