Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Jun 2017
    Posts
    4
    Member #
    56932

    Picture not showing

    0
    down vote
    favorite
    I have used the filedisplay.php?id= method for displaying a product on which user chooses. The picture is displayed on the index from database but is not showing on filedisplay.php

    My filedisplay.php

    <?php
    include 'fileconstant.php';
    // just so we know it is broken
    error_reporting(E_ALL);
    // some basic sanity checks
    if(isset($_GET['id']) && is_numeric($_GET['id'])) {
    //connect to the db
    $link = mysql_connect("$host", "$user", "$pass")
    or die("Could not connect: " . mysql_error());

    // select our database
    mysql_select_db("$db") or die(mysql_error());

    // get the image from the db
    $sql = "SELECT photo FROM products WHERE id=" .$_GET['id'] . ";";

    // the result of the query
    $result = mysql_query("$sql") or die("Invalid query: " . mysql_error());

    // set the header for the image
    header("Content-type: image/jpeg");
    echo mysql_result($result, 0);

    // close the db link
    mysql_close($link);
    }
    else {
    echo 'Please use a real id number';
    }
    ?>

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Is the data from the database a URL to the image file, or is it the image's data URI?
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Junior Member
    Join Date
    Jun 2017
    Posts
    4
    Member #
    56932

    Database to Image

    Database to Image thing

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,686
    Member #
    5580
    Liked
    716 times
    An example more like this ....


    $sql = "SELECT photo FROM products WHERE id = $_GET['id']";
    $sth = $db->query($sql);
    $result=mysqli_fetch_array($sth);
    echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['image'] ).'"/>';



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:49 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com