displaying images from a database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Diz
    New Member
    • Feb 2006
    • 19

    displaying images from a database

    ok..so I can get all of the other information from my database, but when i try to get images, it displays as a code i dont recognise. here is the query:
    <?php
    // Connecting, selecting database
    $link = mysql_connect(' localhost', 'username', 'password')
    or die('Could not connect: ' . mysql_error());
    echo 'Connected successfully';
    mysql_select_db ('webimages') or die('Could not select database');

    // Performing SQL query
    $query = 'SELECT * FROM tbl_artwork';
    $result = mysql_query($qu ery) or die('Query failed: ' . mysql_error());

    // Printing results in HTML
    echo "<table>\n" ;
    while ($line = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {
    echo "\t<tr>\n";
    foreach ($line as $col_value) {
    echo "\t\t<td>$col_v alue</td>\n";
    }
    echo "\t</tr>\n";
    }
    echo "</table>\n";

    // Free resultset
    mysql_free_resu lt($result);
    // Closing connection
    mysql_close($li nk);
    ?>

    and this is the result i get (I've just included one record, but i got a page full of them!):

    Connected successfully000 0000001 Abstract Blue 1 2001 Abstract 250 Yes ÿØÿàJFIF––ÿ ÛC       ÿÛC    ÿÀ xdÿÄ ÿÄ : !"1AQ2B aq#3R‘ÑC 2000*2500mm canvas

    here is the table:
    tbl_artwork
    Field Type Null Default Links to Comments MIME
    artworkID int(10) No
    title varchar(25) No
    dateCreated year(4) No 0000
    category enum('Abstract' , 'Figurative', 'Landscape') No Abstract
    cost int(6) No 0
    forSale enum('Yes', 'No') No Yes
    image tinyblob No
    size varchar(20) Yes NULL
    paintedOn enum('board', 'canvas', 'paper') No board


    Can anybody please help? Thanks,
    Diz
Working...