1 Replies - 1416 Views - Last Post: 16 November 2012 - 02:19 PM Rate Topic: -----

#1 ajthewhiz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 28-October 12

Issue displaying images from mysql database in php

Posted 16 November 2012 - 02:15 PM


I am having problem displaying the actual image on my website. In my website I am having users uploading images so that they can only view their own images. I feel like my code works up until the actual image is not display. Here is my code below

    $userEmail  = $_SESSION['userEmail'];     
    //configure the database
    mysql_connect("localhost", "root", "") or die(include "../database/server.php");    
    mysql_select_db("cis_dept") or die(include "../database/error.php");
    //generate a query
    $sql    = "SELECT image
               FROM student inner join image on student.email = image.studentEmail
               WHERE email = '$userEmail'";               
    $result = mysql_query($sql);
    //include header
    include_once '../attach/header.php'; 
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>View Images - <?php print $_SESSION['userFirst'].' '.$_SESSION['userLast'];?></title>
        <!--add a header that will include links for the pages-->
            <div id="links">
                <label><a href="../student/welcome.php">Home</a></label> |
                <label><a href="../student/upload.php">Upload Image</a></label>
            </div><!--end of links-->
        </header><!---end of header--->        
        <div id="mainContent">           
            <div id="bodyContent">
                <h2>View <?php print $_SESSION['userFirst'];?>'s Images</h2>
                <div class ="uploadInfo">
                        View your images below.
                <div class="register">                    
                                    if(mysql_num_rows($result) == 0)
                                        header("Location: ../student/noImage.php");
                                        while($row = mysql_fetch_array($result))
                                            print '<img src=" '.$row['image']. '" alt="'.$row['image'].'" width="135" height ="100"/>'.' ';                                            
            </div><!---end of body content--->
        </div><!---end of main content-->
    //include footer
    include_once '../attach/footer.php';

In addition here is the image that is causing the issue. Is there anything missing that I need to add to the code?



Attached image(s)

  • Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: Issue displaying images from mysql database in php

#2 BenignDesign  Icon User is offline

  • holy shitin shishkebobs
  • member icon

Reputation: 7501
  • View blog
  • Posts: 12,089
  • Joined: 28-September 07

Re: Issue displaying images from mysql database in php

Posted 16 November 2012 - 02:19 PM

It's not finding the images. Have you double and triple checked your file path for your image display?

It has been my personal experience that 99% of the time my images display with the little red "x", it's one of two things: either I spelled the file name wrong or I listed the file path incorrectly.
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1