Temporary Download link Error [ Solved ]

Post here is you are having problems with any of the tutorials.
Post Reply
Posts: 18
Joined: Fri Jan 27, 2012 8:11 am

Temporary Download link Error [ Solved ]

Post by JuiceYum »

I'm getting an error in my download.php for the temporary download tutorial. The error is

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.



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));


Post Reply