I need help after i used this code was still getting this errors
Warning: Cannot modify header information - headers already sent by (output started at /home/zivamaho/public_html/get_file.php:1) in /home/zivamaho/public_html/get_file.php on line 32
Warning: Cannot modify header information - headers already sent by (output started at /home/zivamaho/public_html/get_file.php:1) in /home/zivamaho/public_html/get_file.php on line 33
Warning: Cannot modify header information - headers already sent by (output started at /home/zivamaho/public_html/get_file.php:1) in /home/zivamaho/public_html/get_file.php on line 34
/tmp/phpR9kTog
this is my code: i used it on cpanel upload but got the above errors. Pls help me out
Warning: Cannot modify header information - headers already sent by (output started at /home/zivamaho/public_html/get_file.php:1) in /home/zivamaho/public_html/get_file.php on line 32
Warning: Cannot modify header information - headers already sent by (output started at /home/zivamaho/public_html/get_file.php:1) in /home/zivamaho/public_html/get_file.php on line 33
Warning: Cannot modify header information - headers already sent by (output started at /home/zivamaho/public_html/get_file.php:1) in /home/zivamaho/public_html/get_file.php on line 34
/tmp/phpR9kTog
this is my code: i used it on cpanel upload but got the above errors. Pls help me out
Code:
<?php
// Make sure an ID was passed
if(isset($_GET['id'])) {
// Get the ID
$id = intval($_GET['id']);
// Make sure the ID is in fact a valid ID
if($id <= 0) {
die('The ID is invalid!');
}
else {
// Connect to the database
$dbLink = mysqli_connect('localhost', 'zivamaho_data', 'hospitality', 'zivamaho_hotel');
if(mysqli_connect_errno()) {
die("MySQL connection failed: ". mysqli_connect_error());
}
// Fetch the file information
$query = "
SELECT first_name,last_name,email,address,phone,mime, name, size, data
FROM file
WHERE `id` = {$id}";
$result = $dbLink->query($query);
if($result) {
// Make sure the result is valid
if($result->num_rows == 1) {
// Get the row
$row = mysqli_fetch_assoc($result);
// Print headers
header("Content-Type:".$row['mime']);
header("Content-Length:".$row['size']);
header("Content-Disposition:attachment;filename=".$row['name']);
// Print data
echo $row['data'];
}
else {
echo 'Error! No image exists with that ID.';
}
// Free the mysqli resources
@mysqli_free_result($result);
}
else {
echo "Error! Query failed: <pre>{$dbLink->error}</pre>";
}
@mysqli_close($dbLink);
}
}
else {
echo 'Error! No ID was passed.';
}
?>
Comment