Sponsored Content
Top Forums Shell Programming and Scripting Downloading show garbage on the screen Post 302853505 by hadinetcat on Saturday 14th of September 2013 07:19:50 PM
Old 09-14-2013
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
Code:
<?php
ob_start();
$company =$_GET['company'];
if(isset($_GET['id']))
{
  $id = intval($_GET['id']);
  if($id <= 0)
  {
    die('The ID is invalid!');
  }
  else
  {
    $dbLink = new mysqli('localhost', 'sqldata', 'sqldata', 'balhaf');
    if(mysqli_connect_errno())
    {
      die("MySQL connection failed: ". mysqli_connect_error());
    }
    $query = "SELECT mime, name, size, data FROM $company WHERE id = $id";
    $result = $dbLink->query($query);
    if($result)
    {
      if($result->num_rows == 1) {
        $row = mysqli_fetch_assoc($result);
        $size = $row['size'];
        $filename = $row['name'];
        $data = $row['data'];
        $mime = $row['mime'];
        ini_get('zlib.output_compression');
        ini_set('zlib.output_compression', 'Off');
        header('Content-Type: application/pdf');
        while (@ob_end_clean());
        header('Content-Disposition: attachment; filename='.($filename));
        header('Content-Length:'.($size));
        echo $data;
        exit();
      }
      else
      {
        echo 'Error! No image exists with that ID.';
      }
      mysqli_free_result($result);
    }
    else
    {
      echo "Error! Query failed: <pre>{$dbLink->error}</pre>";
    }
    mysqli_close($dbLink);
  }
}
else
{
  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.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing Garbage output

I am using following code to read myfile.ddl line by line. But the thing is it is printing lot of garbage which are the names of the files and directories in which myfile.ddl is present. Kindly refine the code so that only myfile.ddl contents are only read LOGFILE="logfile.txt"... (4 Replies)
Discussion started by: skyineyes
4 Replies

2. Shell Programming and Scripting

tail command not show on screen

Hi, I'm moniroting duplicate text with unix command (tail -f trace75747 | grep 'duplicate'), but it showed many lines then it stop show trace information although trace information in this file trace75747 always got. What should I do? I look forward to hearing from you. THANKS! (10 Replies)
Discussion started by: seyha_moth
10 Replies

3. OS X (Apple)

Virtual screen accessed by Screen Sharing

Hi, I'm trying to create a virtual screen, (maybe xvfb? or any other virtual screen buffer) and be able to use Screen Sharing to connect to it. The setup is that I have a Mac Mini connected to the TV. But when my girlfriend is using Front Row, I can't use Screen Sharing at the same time from... (0 Replies)
Discussion started by: linge
0 Replies

4. Shell Programming and Scripting

Logging ALL standard out of a bash script to a log file, but still show on screen

Is it possible to store all standard-out of a bash script and the binaries it calls in a log file AND still display the stdout on screen? I know this is possible to store ALL stdout/stderr of a script to a single log file like: exec 1>&${logFile} exec 2>&1 But running a script with the... (3 Replies)
Discussion started by: ckmehta
3 Replies

5. Programming

strcat outputs garbage

Anyone have any ideas why when using strcat function I would get some garbage at the beginning of the output string? what I'm doing is something like the following example. Code: char temp; char tempHolder; for(int i=0;i<something;i++){ sprintf(temp,"%u ", someVariable);... (2 Replies)
Discussion started by: airon23bball
2 Replies

6. Shell Programming and Scripting

Garbage value

I write a program to find a palindromic region in given sequences. but it dosen't seems to be run well. please give me your suggestions INPUT: AGCTAGCTCGAAGGTAG code is here #!/usr/bin/perl #Palindromic sequence print "enter the sequence:\n"; $rna = <STDIN>; chomp $rna; ... (3 Replies)
Discussion started by: sujit_singh
3 Replies

7. Red Hat

command line tool to disable screen lock and/or screen saver

Hi, I have a simple question : how to disable screen lock and/or sreen saver with command line with RHEL5.4 ? (1 Reply)
Discussion started by: albator1932
1 Replies

8. UNIX for Dummies Questions & Answers

Accidentally made a screen within a screen - how to move it up one level?

I made a screen within a screen. Is there a way to move the inner screen up one level so that it is at the same level as the first screen running from the shell? (2 Replies)
Discussion started by: phpchick
2 Replies

9. UNIX for Beginners Questions & Answers

Some % of Garbage Collection

I need to write a python script that will look at the local gc logs. 6 sys=0.00, real=0.06 secs] 2019-06-05T07:43:12.029-0500: 1072696.494: 2791209K->1995953K(2796544K)] 2803355K->1995953K(4164608K), , 3.0299555 secs] 2019-06-05T07:43:17.149-0500: 1072701.614: 3334321K->2008193K(4167680K),... (1 Reply)
Discussion started by: xgringo
1 Replies
FIREFOX(1)							Linux User's Manual							FIREFOX(1)

NAME
firefox - a Web browser for X11 derived from the Mozilla browser SYNOPSIS
firefox [OPTIONS] [URL] DESCRIPTION
Mozilla Firefox is an open-source web browser, designed for standards compliance, performance and portability. USAGE
firefox is a simple shell script that will set up the environment for the actual executable. OPTIONS
A summary of the options supported by firefox is included below. GTK options --gdk-debug=FLAGS Gdk debugging flags to set --gdk-no-debug=FLAGS Gdk debugging flags to unset --gtk-debug=FLAGS Gtk+ debugging flags to set --gtk-no-debug=FLAGS Gtk+ debugging flags to unset --gtk-module=MODULE Load an additional Gtk module X11 options --display=DISPLAY X display to use --sync Make X calls synchronous --no-xshm Don't use X shared memory extension --xim-preedit=STYLE --xim-status=STYLE --g-fatal-warnings Make all warnings fatal Firefox options -h, -help Show summary of options. -height value Set height of startup window to value. -width value Set width of startup window to value. -v, -version Print /usr/bin/firefox-bin version. -CreateProfile profile Create profile. -P profile Start with profile. -ProfileManager Start with profile manager. -UILocale lang-region Start with lang-region resources. -contentLocale lang-region Start with lang-region resources. -remote command Execute command in an already running Firefox process. For more info, see: http://www.mozilla.org/unix/remote.html -no-remote Don't try to control an already running instance. -jsconsole Start with Javascript Console -chrome url Load the specified chrome. -new-window url Open URL in a new window if Firefox is already running. -new-tab url Open URL in a new tab if Firefox is already running. -preferences Open Firefox preferences menu. -safe-mode Disables extensions and themes for this session. FILES /usr/bin/firefox - shell script wrapping firefox /usr/lib/firefox/firefox - firefox executable VERSION
3.0 BUGS
To report a bug, please visit http://bugzilla.mozilla.org/ SEE ALSO
mozilla(1) AUTHORS
The Mozilla Organization http://www.mozilla.org/about.html firefox January 04, 2006 FIREFOX(1)
All times are GMT -4. The time now is 02:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy