Database getting updated twice

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Areric

    #1

    Database getting updated twice

    Hey all,

    Another question for you.

    I have a script that reads in a row from my db into an image object
    which i defined. It then takes that image and generates a thumbnail by
    using an output buffer and writes the thumbnail to a new entry in the
    database. Finally it prints the new image to the screen via this
    method:

    header("Content-type: ".$image->GetFileType()) ;
    header("Content-length: ".$this->GetFileSize()) ;
    echo $this->GetImageConten t();

    where GetImageContent returns the binary data contained in the image.

    This all seems to work, but when it hits the first header line
    header("Content-type: ".$image->GetFileType()) ;

    it adds a second entry into the database. Basically im ending up with 2
    identical records.

    Ive been trying to figure out how to work around this, and the only
    thing i could think of was that because im calling to header the script
    is getting executed twice. No where in my print function so i have a
    call to save so my question i suppose is, is it possible for a script
    to execute a second time because of a call to header?

  • Jerry Stuckle

    #2
    Re: Database getting updated twice

    Areric wrote:[color=blue]
    > Hey all,
    >
    > Another question for you.
    >
    > I have a script that reads in a row from my db into an image object
    > which i defined. It then takes that image and generates a thumbnail by
    > using an output buffer and writes the thumbnail to a new entry in the
    > database. Finally it prints the new image to the screen via this
    > method:
    >
    > header("Content-type: ".$image->GetFileType()) ;
    > header("Content-length: ".$this->GetFileSize()) ;
    > echo $this->GetImageConten t();
    >
    > where GetImageContent returns the binary data contained in the image.
    >
    > This all seems to work, but when it hits the first header line
    > header("Content-type: ".$image->GetFileType()) ;
    >
    > it adds a second entry into the database. Basically im ending up with 2
    > identical records.
    >
    > Ive been trying to figure out how to work around this, and the only
    > thing i could think of was that because im calling to header the script
    > is getting executed twice. No where in my print function so i have a
    > call to save so my question i suppose is, is it possible for a script
    > to execute a second time because of a call to header?
    >[/color]

    So, what does your GetFileType() function do?


    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Areric

      #3
      Re: Database getting updated twice

      just returns $this->mFileType; where mFileType is a string value along
      the lines of "image/jpeg"

      Comment

      Working...