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
GOZILLA(1)						      General Commands Manual							GOZILLA(1)

NAME
gozilla - force mozilla to display specified source file. SYNOPSIS
gozilla [-b browser][-p][+no] file gozilla [-b browser][-p] -d name DESCRIPTION
Gozilla force mozilla to display specified source file as a hypertext. Gozilla can be used with other browsers like firefox and epiphany. In advance of using this command, you must execute gtags(1) and htags(1) at the root directory of the source tree to make tag files. Then you can execute gozilla at anywhere in the source tree. First form: You can specify source file and the line number optionally. Second form: You can specify definition name directly. Definition name must exist in 'GTAGS' tag file. Some browsers require you to load it before executing gozilla. Whether or not gozilla waits for exiting of browser depends on browser. OPTIONS
The following options are available: +no line number. It must be a line on which function definition or function reference is exist. If you execute htags(1) with -l option, you can specify any line. -b browser browser to use. By default, it is assumed mozilla. -d name print function. --help Show help. -p just print generated target URL. file path of source file or alias name. -q, --quiet Quiet mode. -v, --verbose Verbose mode. --version Show version number. FILES
'HTML/' hypertext of source tree. 'GTAGS/' tags file for function definitions. '$HOME/.gozillarc' alias file. Please read source code for the detail. ENVIRONMENT
GTAGSROOT The directory which is the root of source tree. GTAGSDBPATH The directory on which gtags database exist. This value is ignored when GTAGSROOT is not defined. BROWSER browser to use. By default, it is assumed mozilla. EXAMPLES
$ gtags $ htags $ global -x main main 82 ctags.c main(argc, argv) $ mozilla & $ gozilla +82 ctags.c $ firefox & $ gozilla -b firefox +82 ctags.c $ setenv BROWSER 'epiphany --new-tab' $ epiphany & $ gozilla +82 ctags.c DIAGNOSTICS
Gozilla exits with a non 0 value if an error occurred, 0 otherwise. SEE ALSO
global(1), gtags(1), htags(1), firefox(1), epiphany(1), mozilla(1). GNU GLOBAL source code tag system (http://www.gnu.org/software/global/). NOTES
Gozilla means 'Global for mozilla'. BUGS
Gozilla can treat not only source file but also normal file, directory, HTML file and even URL, because it is omnivorous. AUTHORS
Tama Communications Corporation. HISTORY
The gozilla command appeared in FreeBSD 2.2.2 but did not installed by default. GNU Project July 2006 GOZILLA(1)
All times are GMT -4. The time now is 01:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy