Acid
04-30-2007, 12:36 PM
I wrote this script a little while ago and it's been working fine, now all of a sudden its decided it doesn't want to work anymore and I have no idea why.
I have a bunch of files stored in a MySQL database using BLOB fields, now for some reason when the files are opened the document is corrupted and wont open. Here's the code I'm using to download the files out the database:
<?php
error_reporting(E_ALL ^ E_NOTICE);
require_once("MySQL.php");
$Host = "**********";
$UserName = "**********";
$Password = "**********";
$Database = "**********";
$Vacancies = new MySQL;
$Vacancies->Connect($Host, $UserName, $Password, $Database);
if ($_GET['JobDescID'] || $_GET['KSFID']) {
if ($_GET['JobDescID']) {
$GetFileQuery = $Vacancies->Query("SELECT `JDFileName`, `JDFileType`, `JDFileSize`, `JDFileData` FROM `Files` WHERE `ID` LIKE '" . $Vacancies->Real_Escape_String($_GET['JobDescID']) . "'");
} else if ($_GET['KSFID']) {
$GetFileQuery = $Vacancies->Query("SELECT `KSFFileName`, `KSFFileType`, `KSFFileSize`, `KSFFileData` FROM `Files` WHERE `ID` LIKE '" . $Vacancies->Real_Escape_String($_GET['KSFID']) . "'");
}
if ($Vacancies->Num_Rows($GetFileQuery) == 0) {
$Vacancies->Close();
header("Location: /Vacancies/");
die();
} else {
list($FileName, $FileType, $FileSize, $FileData) = $Vacancies->Fetch_Array($GetFileQuery);
header("Content-length: " . $FileSize);
header("Content-type: " . $FileType);
if ($_GET['Action'] == "Download") {
header("Content-Disposition: attachment; filename=" . $FileName);
}
echo $FileData;
$Vacancies->Close();
}
} else {
$Vacancies->Close();
header("Location: /Vacancies/");
die();
}
?>You can see the problem for your self at the following address:
http://www.tewv.nhs.uk/Vacancies/
Click on anyone of the jobs listed on that page to pull up the job details, at the bottom of the details page you'll see the links to view or download the job descriptions or KSFs (which are the files that wont open that are stored in the database), for instance:
http://www.tewv.nhs.uk/VacancyDetails/65b0d64feb38840167bd451d5adef9b6/
You'll see the links at the bottom of this page. Any help with this would be great, no idea why this has suddenly decided to stop working.
I have a bunch of files stored in a MySQL database using BLOB fields, now for some reason when the files are opened the document is corrupted and wont open. Here's the code I'm using to download the files out the database:
<?php
error_reporting(E_ALL ^ E_NOTICE);
require_once("MySQL.php");
$Host = "**********";
$UserName = "**********";
$Password = "**********";
$Database = "**********";
$Vacancies = new MySQL;
$Vacancies->Connect($Host, $UserName, $Password, $Database);
if ($_GET['JobDescID'] || $_GET['KSFID']) {
if ($_GET['JobDescID']) {
$GetFileQuery = $Vacancies->Query("SELECT `JDFileName`, `JDFileType`, `JDFileSize`, `JDFileData` FROM `Files` WHERE `ID` LIKE '" . $Vacancies->Real_Escape_String($_GET['JobDescID']) . "'");
} else if ($_GET['KSFID']) {
$GetFileQuery = $Vacancies->Query("SELECT `KSFFileName`, `KSFFileType`, `KSFFileSize`, `KSFFileData` FROM `Files` WHERE `ID` LIKE '" . $Vacancies->Real_Escape_String($_GET['KSFID']) . "'");
}
if ($Vacancies->Num_Rows($GetFileQuery) == 0) {
$Vacancies->Close();
header("Location: /Vacancies/");
die();
} else {
list($FileName, $FileType, $FileSize, $FileData) = $Vacancies->Fetch_Array($GetFileQuery);
header("Content-length: " . $FileSize);
header("Content-type: " . $FileType);
if ($_GET['Action'] == "Download") {
header("Content-Disposition: attachment; filename=" . $FileName);
}
echo $FileData;
$Vacancies->Close();
}
} else {
$Vacancies->Close();
header("Location: /Vacancies/");
die();
}
?>You can see the problem for your self at the following address:
http://www.tewv.nhs.uk/Vacancies/
Click on anyone of the jobs listed on that page to pull up the job details, at the bottom of the details page you'll see the links to view or download the job descriptions or KSFs (which are the files that wont open that are stored in the database), for instance:
http://www.tewv.nhs.uk/VacancyDetails/65b0d64feb38840167bd451d5adef9b6/
You'll see the links at the bottom of this page. Any help with this would be great, no idea why this has suddenly decided to stop working.