ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Loading Images from MySQL db to view in CI

October 29, 2009 2:15am

Subscribe [6]
  • #16 / Dec 15, 2010 12:13pm

    vickel

    52 posts

    I’ve done that previously in my CI controller and also tested my working script (outside the CI framwork), the latter works with both the first not at all.

    How do we forward that issue to one of the CI/Expression Engine Gurus? Maybe they know about an issue, like config setting for database, or similar… ???

  • #17 / Dec 15, 2010 2:17pm

    GeoXeo

    7 posts

    do you mean you don’t see any image with following code in a controller ?

    function image() {
            $hex_img = "ffd8ffe000104a46494600010101004800480000fffe00134372656174656420776974682047494d50ffdb004300080606070605080707070909080a0c140d0c0b0b0c1912130f141d1a1f1e1d1a1c1c20242e2720222c231c1c2837292c30313434341f27393d38323c2e333432ffdb0043010909090c0b0c180d0d1832211c213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232ffc00011080064006403012200021101031101ffc4001500010100000000000000000000000000000008ffc40014100100000000000000000000000000000000ffc40014010100000000000000000000000000000000ffc40014110100000000000000000000000000000000ffda000c03010002110311003f009fc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007ffd9";
            Header("Content-type: image/jpeg");
            echo pack("H*", $hex_img);
            
            exit();
        }

    If this is the case, there may be an issue ...

  • #18 / Dec 15, 2010 3:07pm

    vickel

    52 posts

    Yes I can confirm that, only a string when calling the controller function, black square when I call it from outside CI…

  • #19 / Dec 15, 2010 3:28pm

    vickel

    52 posts

    I’ve done some further testing on another domain on a different server, but from the same hosting service. there it works: http://www.bestsurfcamps.com/index.php/backoffice/image
    -strange-

  • #20 / Dec 15, 2010 5:24pm

    vickel

    52 posts

    Hi GeoXeo, i found the reason: in my appl/config files, I checked database.php .... for some reason the code of database.php started with an empty space. Like:

    <<this is a simple empty space>><?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    /*
    | -------------------------------------------------------------------
    | DATABASE CONNECTIVITY SETTINGS
    | -------------------------------------------------------------------
    | ... code continues
    */
    ?>

    once I removed that space, I could see the black image square and my controller works as well….

    conclusion1: f..k space 😊 stay on earth !
    conclusion2: strange that the database connection works for all but the BLOB - have fun CI’s to find that out

  • #21 / Dec 15, 2010 6:45pm

    GeoXeo

    7 posts

    Well done !

    I have another interpretation though ...

    I think that with PHP, each character outside a code block is sent to the output.
    So when you try to send the bytes of the image, a space has already been sent and the http headers have already been sent too.

    When you output text, it may seem to work: you see the page you expected.

    I say ‘seem to work’ because there are some php warning messages that you seem to miss (check error_reporting() in index.php)

    Message: Cannot modify header information - headers already sent by (output started at C:\wamp\www\ci.geoxeo\system\application\config\database.php:1)

    So I would say that there is likely nothing wrong with CI, it’s just PHP stuff

  • #22 / Dec 15, 2010 8:06pm

    vickel

    52 posts

    I’m not picking on CI, not at all ! - it helped me to achieve building some great weblications.

    and you are right, if I try to read a non blob type field, which means not using HEADERS, the result is correct, the blank space doesn’t matter.

    I’ve set error_reporting(E_ALL) but didn’t get any message ?

    Anyway, maybe in a future version of CI, removing blank spaces before and maybe after a “code block” automatically could help avoiding our issue.

    Thanks GeoXeo for your time, I’ve lost a lot of hours, but have learned a lot too, best from Portugal, Vickel

  • #23 / Dec 17, 2010 7:50am

    bonatoc

    19 posts

    — to delete —

  • #24 / Dec 17, 2010 6:15pm

    vickel

    52 posts

    thanks bonatoc, but here we tried to resolve a certain issue. If the solution is good or bad, well that’s another story to discuss. And that story has been discussed furiously in this forum.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases