Downloading show garbage on the screen | Unix Linux Forums | Shell Programming and Scripting

  Go Back    

Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Downloading show garbage on the screen

Shell Programming and Scripting

php, php apache download

Closed Thread    
Thread Tools Search this Thread Display Modes
Old 09-14-2013
hadinetcat hadinetcat is offline
Registered User
Join Date: Jan 2013
Last Activity: 7 February 2015, 1:53 PM EST
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Downloading show garbage on the screen

I have PHP code for downloading pdf files from mysql database. The code is working fine in firefox mozilla and google chrome but not in IE 10, it show garbage in the screen. I have debugged the code with some headers utilities to examine the headers request, it appear the headers is not sending back to the user agent (IE browser) it just blank.

my php code

$company =$_GET['company'];
  $id = intval($_GET['id']);
  if($id <= 0)
    die('The ID is invalid!');
    $dbLink = new mysqli('localhost', 'sqldata', 'sqldata', 'balhaf');
      die("MySQL connection failed: ". mysqli_connect_error());
    $query = "SELECT mime, name, size, data FROM $company WHERE id = $id";
    $result = $dbLink->query($query);
      if($result->num_rows == 1) {
        $row = mysqli_fetch_assoc($result);
        $size = $row['size'];
        $filename = $row['name'];
        $data = $row['data'];
        $mime = $row['mime'];
        ini_set('zlib.output_compression', 'Off');
        header('Content-Type: application/pdf');
        while (@ob_end_clean());
        header('Content-Disposition: attachment; filename='.($filename));
        echo $data;
        echo 'Error! No image exists with that ID.';
      echo "Error! Query failed: <pre>{$dbLink->error}</pre>";
  echo 'Error! No ID was passed.';

Last edited by Scott; 09-14-2013 at 09:03 PM.. Reason: Please use code tags, and indent code. Thanks.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
command line tool to disable screen lock and/or screen saver albator1932 Red Hat 1 10-20-2011 05:43 PM
Logging ALL standard out of a bash script to a log file, but still show on screen ckmehta Shell Programming and Scripting 3 09-29-2009 05:19 PM
tail command not show on screen seyha_moth Shell Programming and Scripting 10 12-27-2008 10:26 AM
new NIC card doesn't show in show-nets iperez Solaris 13 09-26-2008 05:52 AM

All times are GMT -4. The time now is 08:29 AM.