Browser Issue

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

    Browser Issue

    I have written the following code as a test, (yes I know it is a
    resource hog). Basically it pulls all images out of a MySQL table.

    <?php
    $conn = mysql_connect(h ost, user, pass);
    mysql_select_db (testuser, $conn);

    $query = "SELECT * FROM gallery";
    $result = mysql_query($qu ery, $conn);

    echo "<table width=\"50%\" align=\"center\ ">";
    while($row = mysql_fetch_arr ay($result))
    {
    echo "<tr>";
    echo "<td>$row[NAME] <br> $row[DESC] </td>";
    echo "<td><IMG SRC=\"data:imag e/jpeg;base64," .
    base64_encode($ row[IMG]) . "\"></td>";
    }
    echo "</table>";
    mysql_close($co nn);
    ?>

    Now I don't know where my problem is, but, when viewed with firefox, the
    images load correctly, however when viewed with Internet explorer, the
    images do not load.

    You can see a example of the script in action at


    Does anyone know why the images will not show up in IE correctly?
  • ColdShine

    #2
    Re: Browser Issue

    Materialised in news:4a6e21Frov 70U1@individual .net wrote:

    [...][color=blue]
    > echo "<td><IMG SRC=\"data:imag e/jpeg;base64," .
    > base64_encode($ row[IMG]) . "\"></td>";[/color]
    [...][color=blue]
    >
    > Now I don't know where my problem is, but, when viewed with firefox, the
    > images load correctly, however when viewed with Internet explorer, the
    > images do not load.
    >
    > You can see a example of the script in action at
    > http://codegurus.org/~mwalker/test.php
    >
    > Does anyone know why the images will not show up in IE correctly?[/color]

    AFAIK IE doesn't recognize <img> tags with inline source. No wonder you only
    see it working in Firefox (and probabily Opera, too).

    --
    ColdShine

    "Experience is a hard teacher: she gives the test first, the lesson
    afterwards." - Vernon Sanders law


    Comment

    • Materialised

      #3
      Re: Browser Issue

      ColdShine wrote:[color=blue]
      > Materialised in news:4a6e21Frov 70U1@individual .net wrote:
      >
      > [...][color=green]
      >> echo "<td><IMG SRC=\"data:imag e/jpeg;base64," .
      >> base64_encode($ row[IMG]) . "\"></td>";[/color]
      > [...][color=green]
      >> Now I don't know where my problem is, but, when viewed with firefox, the
      >> images load correctly, however when viewed with Internet explorer, the
      >> images do not load.
      >>
      >> You can see a example of the script in action at
      >> http://codegurus.org/~mwalker/test.php
      >>
      >> Does anyone know why the images will not show up in IE correctly?[/color]
      >
      > AFAIK IE doesn't recognize <img> tags with inline source. No wonder you only
      > see it working in Firefox (and probabily Opera, too).
      >[/color]
      Thanks for your reply.
      Do you know of any work arounds?

      Comment

      • fletch

        #4
        Re: Browser Issue

        Save the image to a file. Not sure why the images are not in a file
        anyway. Never could understand putting the images in a db.

        Comment

        • Materialised

          #5
          Re: Browser Issue

          fletch wrote:[color=blue]
          > Save the image to a file. Not sure why the images are not in a file
          > anyway. Never could understand putting the images in a db.
          >[/color]
          As I previously said, I have my reasons for storing the image to a database.
          The main one is for secondary back up purposes.

          Comment

          • fletch

            #6
            Re: Browser Issue

            > As I previously said, I have my reasons for storing the image to a database.

            Not in this thread.

            You _must_ have files that need backing up as well? Do you know of
            rsync?

            It is much more efficient to let the webserver deliver images directly,
            and as I see it, there is no _good_ reason not to go that route.

            Comment

            • Materialised

              #7
              Re: Browser Issue

              fletch wrote:[color=blue][color=green]
              >> As I previously said, I have my reasons for storing the image to a database.[/color]
              >
              > Not in this thread.
              >
              > You _must_ have files that need backing up as well? Do you know of
              > rsync?
              >
              > It is much more efficient to let the webserver deliver images directly,
              > and as I see it, there is no _good_ reason not to go that route.
              >[/color]
              The client specifies the backup medium, mine is not to question why. lol

              Comment

              • fletch

                #8
                Re: Browser Issue

                Ah one of _those_ clients. I have a few of them. Urgh. Like the one who
                wanted a web based test which was to be delivered on CDRom and run on
                only one laptop. My Javascript skills improved a lot though.

                Comment

                • Jerry Stuckle

                  #9
                  Re: Browser Issue

                  Materialised wrote:[color=blue]
                  > ColdShine wrote:
                  >[color=green]
                  >> Materialised in news:4a6e21Frov 70U1@individual .net wrote:
                  >>
                  >> [...]
                  >>[color=darkred]
                  >>> echo "<td><IMG SRC=\"data:imag e/jpeg;base64," .
                  >>> base64_encode($ row[IMG]) . "\"></td>";[/color]
                  >>
                  >> [...]
                  >>[color=darkred]
                  >>> Now I don't know where my problem is, but, when viewed with firefox, the
                  >>> images load correctly, however when viewed with Internet explorer, the
                  >>> images do not load.
                  >>>
                  >>> You can see a example of the script in action at
                  >>> http://codegurus.org/~mwalker/test.php
                  >>>
                  >>> Does anyone know why the images will not show up in IE correctly?[/color]
                  >>
                  >>
                  >> AFAIK IE doesn't recognize <img> tags with inline source. No wonder
                  >> you only see it working in Firefox (and probabily Opera, too).
                  >>[/color]
                  > Thanks for your reply.
                  > Do you know of any work arounds?[/color]

                  What you need to do is create a PHP file to fetch the image, i.e. similar to:

                  getpic.php:
                  <?
                  if ($_GET['pid']) {
                  (connect to database and fetch row into $data)
                  header('Content : image/jpeg');
                  echo $data;
                  }

                  Then call it with

                  <img src="getpic.php ?id=1">




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

                  Comment

                  • Jerry Stuckle

                    #10
                    Re: Browser Issue

                    fletch wrote:[color=blue][color=green]
                    >>As I previously said, I have my reasons for storing the image to a database.[/color]
                    >
                    >
                    > Not in this thread.
                    >
                    > You _must_ have files that need backing up as well? Do you know of
                    > rsync?
                    >
                    > It is much more efficient to let the webserver deliver images directly,
                    > and as I see it, there is no _good_ reason not to go that route.
                    >[/color]

                    Sure - there are very good reasons for keeping images in the database. I also
                    do it when appropriate.

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

                    Comment

                    • fletch

                      #11
                      Re: Browser Issue

                      > Sure - there are very good reasons for keeping images in the database. I also[color=blue]
                      > do it when appropriate.[/color]

                      You can't leave it there! What are they!

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: Browser Issue

                        fletch wrote:[color=blue][color=green]
                        >>Sure - there are very good reasons for keeping images in the database. I also
                        >>do it when appropriate.[/color]
                        >
                        >
                        > You can't leave it there! What are they!
                        >[/color]

                        Sure I can! :-)

                        Right off the top of my head - right now I'm working on a catalog of products to
                        display. Products come and go regularly; additionally sometimes we get a new
                        image for an item, so those also are dynamic. And all is updated through web pages.

                        Keeping the image in the database with the rest of the data prevents broken
                        links because files are erased, makes it easier to update a picture in the
                        database and automatically deletes the picture when the product is deleted.

                        Plus the database is much more dynamic than the rest of the site. The database
                        will be backed up daily, while the rest of the site only about once a month.

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

                        Comment

                        • Gerry Vandermaesen

                          #13
                          Re: Browser Issue

                          Storing images in a database can be quite appropriate if the record and
                          the image are considered a single entity.

                          This way your application doesn't need to bother with storing the
                          images on the filesystem, and for example deleting them when you delete
                          or update the record. You also are sure your images don't get deleted
                          from the filesystem while they are still being referenced in a database
                          record.

                          So even if you trade in some DB performance for this design, in some
                          cases it still can be justified.

                          fletch wrote:[color=blue][color=green]
                          > > Sure - there are very good reasons for keeping images in the database. I also
                          > > do it when appropriate.[/color]
                          >
                          > You can't leave it there! What are they![/color]

                          Comment

                          • Andy Jeffries

                            #14
                            Re: Browser Issue

                            On Thu, 13 Apr 2006 01:42:45 -0700, fletch wrote:[color=blue]
                            > It is much more efficient to let the webserver deliver images directly,
                            > and as I see it, there is no _good_ reason not to go that route.[/color]

                            What about situations where there are multiple front-end web servers
                            connecting to multiple database servers.

                            You don't really want to allow users to upload images (profiles, forums,
                            etc) in to a folder on one of the machines (whichever one of the farm they
                            happen to connect to for the upload process) and then have to sync between
                            every server to every other server every few minutes.

                            Of course, shared storage (NFS etc) is another way of getting the same
                            goal, but multiple DBs may be more fault tolerant.

                            Cheers,


                            Andy

                            --
                            Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
                            http://www.gphpedit.org | PHP editor for Gnome 2
                            http://www.andyjeffries.co.uk | Personal site and photos

                            Comment

                            • d

                              #15
                              Re: Browser Issue

                              "Gerry Vandermaesen" <gerry.vanderma esen@gmail.com> wrote in message
                              news:1144934307 .067941.274930@ v46g2000cwv.goo glegroups.com.. .[color=blue]
                              > Storing images in a database can be quite appropriate if the record and
                              > the image are considered a single entity.
                              >
                              > This way your application doesn't need to bother with storing the
                              > images on the filesystem, and for example deleting them when you delete
                              > or update the record. You also are sure your images don't get deleted
                              > from the filesystem while they are still being referenced in a database
                              > record.[/color]

                              So it's a case of slowing down the user's experience because the coder was
                              too lazy to figure out how to link files to database records accurately? :)
                              [color=blue]
                              > So even if you trade in some DB performance for this design, in some
                              > cases it still can be justified.[/color]

                              I've not yet heard a good reason ;)
                              [color=blue]
                              > fletch wrote:[color=green][color=darkred]
                              >> > Sure - there are very good reasons for keeping images in the database.
                              >> > I also
                              >> > do it when appropriate.[/color]
                              >>
                              >> You can't leave it there! What are they![/color]
                              >[/color]


                              Comment

                              Working...