Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    blob image problem

    ok ive been trawling through so many tutorials and just cant seem to get this to work. i want to be able to display a blob jpeg file in a table on a html page.

    PHP Code:
    <html>

    <head>
    <title>The Bassment: Photo Gallery</title>
    </head>

    <BODY bgcolor="#006699">
    <?php
    $db_host 
    'localhost';
    $db_user '*****';
    $db_pwd '*****';

    $database 'jenkem_flash';
    $table 'ae_gallery';

    if (!
    mysql_connect($db_host$db_user$db_pwd))
        die(
    "Can't connect to database");

    if (!
    mysql_select_db($database))
        die(
    "Can't select database");

    // sending query
    $result mysql_query("SELECT * FROM {$table} order by id");
    if (!
    $result) {
        die(
    "Query to show fields from table failed");
    }

    $fields_num mysql_num_fields($result);

    echo 
    "<h1>Photo Gallery</h1>";
    echo 
    "<table border='2'><tr>";
    // printing table headers
    for($i=0$i<$fields_num$i++)
    {
        
    $field mysql_fetch_field($result);
        echo 
    "<td><b>{$field->name}</b></td>";
    }
    echo 
    "</tr>\n";
    // printing table rows
    while($row mysql_fetch_row($result))
    {
        echo 
    "<tr>";

        
    // $row is array... foreach( .. ) puts every element
        // of $row to $cell variable
        
    foreach($row as $cell)
            echo 
    "<td>$cell</td>";

        echo 
    "</tr>\n";
    }
    mysql_free_result($result);
    ?>
    </body>
    </html>
    This code outputs a html table with all the field headings and information, however for the actual blob file all that comes out is a bunch of jargonned syntax. any help would be so much appreciated

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,107
    Thanks
    2
    Thanked 326 Times in 318 Posts
    You probably need to start by learning the HTML necessary to place an image on a web page - http://www.w3schools.com/html/html_images.asp

    You cannot output image data directly on a web page. You need to use an <img src="url_to_image"...> tag for each image. The browser then fetches each image through the url in the src="..." parameter.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Regular Coder
    Join Date
    Dec 2007
    Location
    Nebraska
    Posts
    113
    Thanks
    0
    Thanked 2 Times in 2 Posts
    HTML is HTML, images are images. Those images need to be separate files. Technically, there is a way for them to be in the same document, but that is not likely to be what you are looking for.
    Deliver yesterday, code today, think tomorrow.


  •  

    Posting Permissions

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