PHP+MSSQL

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

    PHP+MSSQL

    Hi frenz

    Lately I try to use MSSQL and PHP , the problem arise when PHP try to
    read MSSQL field with 'image' data type,

    header("Content-type: image/jpeg"); // act as a jpg file to browser

    I try to used normal working file that store BLOB as file type in MSSQL
    ...but still not working. Is it because the image data type in MSSQL can
    not be recognise by PHP?
    Any one can give the hint.. thanks u in advance.

  • Polaris

    #2
    Re: PHP+MSSQL

    If I understand you correctly, you put the image itself into the database?
    Why ?
    better is to put the link in the database and the image itself in the map in
    the link is mutch better.

    "badz" <badz22@gmail.c om> schreef in bericht
    news:1101679138 .676387.56910@z 14g2000cwz.goog legroups.com...[color=blue]
    > Hi frenz
    >
    > Lately I try to use MSSQL and PHP , the problem arise when PHP try to
    > read MSSQL field with 'image' data type,
    >
    > header("Content-type: image/jpeg"); // act as a jpg file to browser
    >
    > I try to used normal working file that store BLOB as file type in MSSQL
    > ..but still not working. Is it because the image data type in MSSQL can
    > not be recognise by PHP?
    > Any one can give the hint.. thanks u in advance.
    >[/color]


    Comment

    • Gary L. Burnore

      #3
      Re: PHP+MSSQL

      On Mon, 29 Nov 2004 00:24:24 +0100, "Polaris"
      <ask4polaris@ho tmail.com> wrote:

      Stop top posting.
      [color=blue]
      >If I understand you correctly, you put the image itself into the database?
      >Why ?
      >better is to put the link in the database and the image itself in the map in
      >the link is mutch better.[/color]

      If you're saying put the image on a filesystem instead of in a
      database, then you're missing rhe point of using a database.

      [color=blue]
      >
      >"badz" <badz22@gmail.c om> schreef in bericht
      >news:110167913 8.676387.56910@ z14g2000cwz.goo glegroups.com.. .[color=green]
      >> Hi frenz
      >>
      >> Lately I try to use MSSQL and PHP , the problem arise when PHP try to
      >> read MSSQL field with 'image' data type,
      >>
      >> header("Content-type: image/jpeg"); // act as a jpg file to browser
      >>
      >> I try to used normal working file that store BLOB as file type in MSSQL
      >> ..but still not working. Is it because the image data type in MSSQL can
      >> not be recognise by PHP?
      >> Any one can give the hint.. thanks u in advance.
      >>[/color]
      >[/color]

      --
      gburnore@databa six dot com
      ---------------------------------------------------------------------------
      How you look depends on where you go.
      ---------------------------------------------------------------------------
      Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
      | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
      DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
      | ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
      Black Helicopter Repair Svcs Division | Official Proof of Purchase
      =============== =============== =============== =============== ===============
      Want one? GET one! http://signup.databasix.com
      =============== =============== =============== =============== ===============

      Comment

      • badz

        #4
        Re: PHP+MSSQL

        what I means is I tried to pull the image from MSSQL database which
        used image as their data type not BLOB..
        is it the reason I can not pull the image..
        by the way the MSSQL table that I used is "view table"

        Comment

        • Tom Szabo

          #5
          Re: PHP+MSSQL

          ?[color=blue][color=green]
          > >Why ?
          > >better is to put the link in the database and the image itself in the map[/color][/color]
          in[color=blue][color=green]
          > >the link is mutch better.[/color]
          >
          > If you're saying put the image on a filesystem instead of in a
          > database, then you're missing rhe point of using a database.
          >[/color]

          Or perhaps you are missing the point of simplicity and speed and
          reliability.

          Horses for courses. If it is something sensitive, yes storing in a database
          is a reasonable solution.

          If it is not sensitive at all, one must have the MS bug to do something like
          that...

          Regards,

          Tom


          Comment

          • Gary L. Burnore

            #6
            Re: PHP+MSSQL

            On Mon, 29 Nov 2004 22:42:31 +1000, "Tom Szabo" <tom@intersoft. net.au>
            wrote:
            [color=blue]
            >?[color=green][color=darkred]
            >> >Why ?
            >> >better is to put the link in the database and the image itself in the map[/color][/color]
            >in[color=green][color=darkred]
            >> >the link is mutch better.[/color]
            >>
            >> If you're saying put the image on a filesystem instead of in a
            >> database, then you're missing rhe point of using a database.
            >>[/color]
            >
            >Or perhaps you are missing the point of simplicity and speed and
            >reliability.
            >
            >Horses for courses. If it is something sensitive, yes storing in a database
            >is a reasonable solution.
            >
            >If it is not sensitive at all, one must have the MS bug to do something like
            >that...
            >
            >[/color]

            You don't know much about databases, eh?

            A well written program with a well designed database can deliver your
            miages quite quickly. Depending on the database, it can be twice as
            fast or only somewhat faster. It's seldom slower than having
            thousands of files in a directory for a program to search through.

            It also has nothing to do with Microsoft.

            Now if you could just learn how to attribute correctly, you'd have the
            medium of USENet to list among things you know how to do.
            --
            gburnore@databa six dot com
            ---------------------------------------------------------------------------
            How you look depends on where you go.
            ---------------------------------------------------------------------------
            Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
            | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
            DataBasix | ÝÛ³ºÝ³Þ³ºÝ³³ÝÛº ݳ޳ºÝ³Ý³Þ³ºÝ³Ý ÝÛ³
            | ÝÛ³ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ÝÛ³
            Black Helicopter Repair Svcs Division | Official Proof of Purchase
            =============== =============== =============== =============== ===============
            Want one? GET one! http://signup.databasix.com
            =============== =============== =============== =============== ===============

            Comment

            • Tom Szabo

              #7
              Re: PHP+MSSQL

              > You don't know much about databases, eh?[color=blue]
              >
              > A well written program with a well designed database can deliver your
              > miages quite quickly. Depending on the database, it can be twice as
              > fast or only somewhat faster. It's seldom slower than having
              > thousands of files in a directory for a program to search through.
              >
              > It also has nothing to do with Microsoft.
              >
              > Now if you could just learn how to attribute correctly, you'd have the
              > medium of USENet to list among things you know how to do.[/color]


              Well I may not know much about them, but at least have 10 years of
              experience and currently working on one similiar project and have one
              program running for 3 years without a hickup with a few 100K pictures (0.5
              TByte on Raid 5 controller). Well, I may not be doing things the way MS and
              other "Authoritie s" suggest, but I usually end up with rock solid
              solutions...

              ....my programs don't utilise the Registry, but they can be easily installed,
              don't screw up, and have never done one machine, and one can run multiple
              copies of it at the same time, if for same strange reason one needs to. One
              may also run older versions of the same thing simultaneously. ..etc

              This is not because of my higher IQ or because I am a smarter programmer. I
              think it is simply because I don't overcomplicate things when it is not
              needed...

              I beleive in simple and elegant solutions, simple straight logic.

              I still think, horses for courses! I like to see how will you deliver a
              number of pictures from a database significantly quicker through an SQL
              server than straight from a well organised Hierachical File Structure, which
              gets pretty close to optimal binary search....

              considering that you have to read the data from a hard-drive into say an SQL
              server, than feed it to IIS

              opposed to sending a link to the browser and IIS sends the files
              down....also I am curious which will be more processor hungry?

              And I agree with you on that a lot depend on the iumplementation :-)

              Regards,

              Tom



              Comment

              • Chung Leong

                #8
                Re: PHP+MSSQL


                "badz" <badz22@gmail.c om> wrote in message
                news:1101679138 .676387.56910@z 14g2000cwz.goog legroups.com...[color=blue]
                > Hi frenz
                >
                > Lately I try to use MSSQL and PHP , the problem arise when PHP try to
                > read MSSQL field with 'image' data type,
                >
                > header("Content-type: image/jpeg"); // act as a jpg file to browser
                >
                > I try to used normal working file that store BLOB as file type in MSSQL
                > ..but still not working. Is it because the image data type in MSSQL can
                > not be recognise by PHP?
                > Any one can give the hint.. thanks u in advance.
                >[/color]

                I use MSSQL in my project and manage to store/retrieve images from the
                database with no problem. Here's what I suggest:

                Check mssql.textsize in php.ini. If I remember correctly it affect blob as
                well text type. Alternatively you could get the pointer to the blob and
                retrieve the data a small chunk at a time using readtext.

                Check the routine that stores the images. Maybe the image never made it into
                the database in the first place. I can't remember what it is exactly but
                there's a limit to how long a SQL statement can be in MSSQL.


                Comment

                • badz

                  #9
                  Re: PHP+MSSQL

                  Hi frenz

                  first the image is put inside the db because of the user want it kept
                  the information inside the db not in specific folder or dir. Off course
                  there have issue on this, but the image file is not so big.

                  I had increase the file size in php.ini but the image seems not appear
                  at all.
                  I had use asp script and its able to display the image correctly, it
                  prove that there is no problem occur while inserting the image.

                  any one can share part of the code in retrieiving the image..
                  again the image is not 'BLOB data type' but MSSQL special 'image data
                  type'

                  Comment

                  • Chung Leong

                    #10
                    Re: PHP+MSSQL


                    "badz" <badz22@gmail.c om> wrote in message
                    news:1101803479 .669986.122700@ f14g2000cwb.goo glegroups.com.. .[color=blue]
                    > Hi frenz
                    >
                    > first the image is put inside the db because of the user want it kept
                    > the information inside the db not in specific folder or dir. Off course
                    > there have issue on this, but the image file is not so big.
                    >
                    > I had increase the file size in php.ini but the image seems not appear
                    > at all.
                    > I had use asp script and its able to display the image correctly, it
                    > prove that there is no problem occur while inserting the image.
                    >
                    > any one can share part of the code in retrieiving the image..
                    > again the image is not 'BLOB data type' but MSSQL special 'image data
                    > type'
                    >[/color]

                    Image = Blob in Microsoft-speak. There's nothing special about it. Just a
                    blob of binary data.

                    I don't know what you mean by 'file size in php.ini'. The settings that you
                    need to change are mssql.textsize and mssql.textlimit .

                    Again, PHP has no problem dealing if blobs from MS SQLServer. All you have
                    to do is select the column. You might need to place the blob column last.
                    Other than that it doesn't behave differently from other columns.

                    Post the actual code if you're still having problem. Kinda hard to guess at
                    what you're actually doing.


                    Comment

                    • hipnautic@gmail.com

                      #11
                      Re: PHP+MSSQL

                      I am having the same problem with printing images via php from mssql.
                      I am not able to print out the image from the mssql database via php,
                      but the other "text" data returns normally. Here's the part of the
                      code that prints the image correctly via a php-mysql relationship but
                      won't work correctly in php-mssql:

                      <?

                      include("databa seAccess.php");
                      $Link = odbc_connect($D SN, $User, $Password);

                      $SqlQuery = "SELECT * FROM uml WHERE ID=".$_GET["iid"];
                      $QueryResult = odbc_do ($Link, $SqlQuery);

                      if (odbc_num_rows( $QueryResult)>0 )
                      {
                      $Row = @odbc_fetch_arr ay ($QueryResult);
                      $image_type = $Row["Type"];
                      $image = $Row["Image"];
                      Header ("Content-type: $image_type");
                      print $image;
                      }
                      ?>

                      Any help would be appreciated! Thanks!
                      ?>


                      [color=blue]
                      > Image = Blob in Microsoft-speak. There's nothing special about it.[/color]
                      Just a[color=blue]
                      > blob of binary data.
                      >
                      > I don't know what you mean by 'file size in php.ini'. The settings[/color]
                      that you[color=blue]
                      > need to change are mssql.textsize and mssql.textlimit .
                      >
                      > Again, PHP has no problem dealing if blobs from MS SQLServer. All you[/color]
                      have[color=blue]
                      > to do is select the column. You might need to place the blob column[/color]
                      last.[color=blue]
                      > Other than that it doesn't behave differently from other columns.
                      >
                      > Post the actual code if you're still having problem. Kinda hard to[/color]
                      guess at[color=blue]
                      > what you're actually doing.[/color]

                      Comment

                      • badz

                        #12
                        Re: PHP+MSSQL

                        I think this ancient problem..
                        since no one come with the answer...
                        I had serach for the answer.. for quite long time....
                        any one can help???

                        Comment

                        Working...