Results 1 to 2 of 2

Thread: display image from database with links

  1. #1
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default display image from database with links


    I'm developing a wap site using wml and php.
    my php code is retrievig and displaying blob image from database.
    but i cannot include any wml part to this page.
    actually i want to display image from database with some links.
    is it possible ?give me any sample code... plz help me....


    my code is.......



    <?php
    function db_connect($user='root', $password='admin', $db='example')
    {
    mysql_connect('localhost', $user, $password) or die('I cannot connect to db: ' . mysql_error());
    mysql_select_db('example');
    }
    // echo "hellow world";
    db_connect();
    $sql = "select imgdata from pix where title=1";
    $result = mysql_query("$sql");
    while($row = mysql_fetch_array($result))
    {
    $bytes = $row['imgdata'];
    }
    header("Content-type: image/jpeg");
    print $bytes;

    exit ();
    mysql_close();
    ?>


    --------------------------------------------------------------------------

    OUTPUT : DISPLAYING IMAGE
    --------------------------------------------------------------------------

    BUT IF I REMOVE COMMENT FOR echo "hellow world"; THE OUTPUT WILL B LIKE THIS

    -------------------------------------------------------------------------

    hellow world

    Warning: Cannot modify header information - headers already sent by
    (output started at C:\web\htdocs\show\image.php:7) in C:\web\htdocs\show\image.php on line 15

    JFIF`` ExifMM*bj(1r2iЦ'
    H?ۄtDi?c:+t㇦fg
    \,3cr]CqXsy?8"ݑS ;{X
    _b(qKul?ΦW K. ;_st?߹C
    }}sN ?^tjv-M
    ?*;/WV]Ԟo}2<9V9=

    u}6m=Ĺ}"k?+:XXNv=eNsZk

    \ẶrOB蘹tLdb<[6 YP]3Ư
    +:ncEU{[\\zj?^t&]S@XVz
    ??.kquEvC=Wڴ };F6cqQ?A ?B
    S${W3W5VHղ
    2x?ILUù)\CJ][?1̢̇[K ....

  2. #2
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    To display an image, you can only output the image. You cannot output anything else before of after the image. The way to put the image in a page is like this:

    Code:
    <img src="./image_script.php" />
    The image tag opens the PHP script and displays the image for you. Example:

    Code:
    <?php
    echo <<<END;
        <html>
    <head>
        <title>image</title>
    </head>
    <body>
        <p>Below is an image</p>
        <img src="./image_script.php" />
    </body>
        <html>
    END;
    ?>
    (where image_script.php is the PHP script that produces the image)
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •