Announcement

Collapse
No announcement yet.

Help !!!! Is it possible to show an image stored in database ??

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help !!!! Is it possible to show an image stored in database ??

    Hi all,

    I've stored logos I use on header and within PDF reports on a table called logos with a single logos_ID = '1'.
    Fields of tables are logo_50, logo_100 and logo_200.
    If I change them for different customers all application will use the logo of that customer without manually go to substitute them on all forms and reports.
    My goal is to use them on form header using Value ---> [glo_logo_50] or [glo_logo_100] or [glo_logo_200]

    On app_Login application, that is the first form to make the login I would like to try to use within onApplicationInit the following lines:

    $sql_logo_50 ="SELECT logo_50 FROM logos WHERE (logos_ID = '1')";
    header ("Content-type: image/png");
    [glo_logo_50] = imagepng($sql_logo_50);

    I'm not a programmer so I would like to have your support about what I'm trying to do.
    Does it make sense ??
    Do I have to change something of previous code ??
    Thanks
    Giovannino

  • #2
    mmmm, I don't know. Of course you can store images in the database, but to apply them in a global variable... I think that's not gonna work.

    I like the idea, but it's not the approach I would choose. You can store html in the header like a link to an image. I would store the url in the database and then the global var would contain the <img... to refer to an image. The images I would upload in a standard images directory.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment


    • #3
      Yes, I did it for istance in the same way for the logo of my company that's the same for all customers and do not change in every implementation.
      This is the line and on the header of app_Login form I use Valuer = [link5site]:
      [link5site] = '<a href="http://www.kfive.it" target="_blank"> <img src="/associations/_lib/img/sys__NM__Kfive_Logo.png" border="0" /></a>';

      For the other "customer specific" logos I would like to find a DB image solution becouse, as you know, many times you have to fight with grant, permission, 775 777 stuff and is quite time consuming. Not all the customers gives you this possibilities.

      If you are a good programmer let make a try ;-) and let me know if it's possible or not !!
      Bye
      Giovannino

      Comment


      • #4
        You may want to read this thread...
        Read the entire posting, evidently there are performance issues with storing them..
        But you can always try..

        http://stackoverflow.com/questions/1...base-using-php

        Comment


        • #5
          After many test I founded a solution !!! YEAHHHHHHHHHH !!!

          $sql_logo = "SELECT logo_50 FROM logos WHERE logos_ID = '1'";
          sc_lookup(my_logo50, $sql_logo);
          [glo_Logo_50]={my_logo50[0][0]};
          echo '<img src="data:image/png;base64,' . base64_encode( [glo_Logo_50] ) . '" />';

          Bye

          Comment


          • #6
            well done! But it only works if it's the first code to be executed?
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment


            • #7
              I did it the same for other logos. But I don't know if your question is different.

              $sql_logo50 = "SELECT logo_50 FROM logos WHERE logos_ID = '1'";
              sc_lookup(my_logo50, $sql_logo50);
              [logo_50] = {my_logo50[0][0]};
              [glo_logo_50] = echo '<img src="data:image/png;base64,' . base64_encode([logo_50]) . '" />';

              $sql_logo100 = "SELECT logo_100 FROM logos WHERE logos_ID = '1'";
              sc_lookup(my_logo100, $sql_logo100);
              [glo_logo_100]={my_logo100[0][0]};
              //echo '<img src="data:image/png;base64,' . base64_encode( [glo_logo_100] ) . '" />';

              $sql_logo_footer = "SELECT logo_footer FROM logos WHERE logos_ID = '1'";
              sc_lookup(my_logo_footer, $sql_logo_footer);
              [glo_logo_footer]={my_logo_footer[0][0]};
              //echo '<img src="data:image/png;base64,' . base64_encode( [glo_logo_footer] ) . '" />';

              $sql_logo_header = "SELECT logo_header FROM logos WHERE logos_ID = '1'";
              sc_lookup(my_logo_header, $sql_logo_header);
              [glo_logo_header]={my_logo_header[0][0]};
              //echo '<img src="data:image/png;base64,' . base64_encode( [glo_logo_header] ) . '" />';

              Comment


              • #8
                Another hint:

                If you use on header or footer using "value" = [glo_logo_50] you have to modify it a bit like the following (without echo):

                $sql_logo50 = "SELECT logo_50 FROM logos WHERE logos_ID = '1'";
                sc_lookup(my_logo50, $sql_logo50);
                [logo_50] = {my_logo50[0][0]};
                [glo_logo_50] = '<img src="data:image/png;base64,' . base64_encode([logo_50]) . '" />';

                Comment


                • #9
                  Hello Giovanni,

                  trying the same as u but become this error

                  Fatal error: Call to a member function Execute() on a non-object

                  If i take my code in onLoad i have no error message, only when i place it in onApplicationinit

                  Do you have an idea ?

                  Comment


                  • #10
                    If you put the code in onapplication init then it's executed when the application is loaded.You don't have a database connection then. So all database access will run into an error.,
                    Albert Drent
                    aducom software netherlands
                    scriptcase partner, reseller, support and (turn-key) development
                    www.scriptcase.eu / www.scriptcase.nl

                    Comment


                    • #11
                      hello Albert,
                      seems that you are right, but Giovanni said that it works, so i wonder how he got it working

                      Comment


                      • #12
                        i find out that if you execute a code SQL in onapplicationinit show a error from database, BUT if you put a select before it works fine!!.
                        for example i run this line before my SQL and it works fine.

                        sc_lookup(rs, "SELECT 1");

                        sc_lookup(rs, $mysql);

                        Comment


                        • #13
                          Ok, but what's the advantage of this trick above the formal way of doing it in onscriptinit?
                          Albert Drent
                          aducom software netherlands
                          scriptcase partner, reseller, support and (turn-key) development
                          www.scriptcase.eu / www.scriptcase.nl

                          Comment


                          • #14
                            in a grid editable On scriptinit is executed every time you: load the form or add a new record or update a record. while onapplicationinit is executed only a time when the form is loaded.

                            so that if need have global values from database, i think that is good idea to access i this event.

                            Comment

                            Working...
                            X