problem in display the image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sravani1
    Banned
    New Member
    • Mar 2008
    • 10

    #1

    problem in display the image

    Hi I got the problem when run this code.That is when i retrive the data and image from the database table same image will displayed all that time when i give the different images .But other fields correctly displayed . plz tell the problem in that code.
    [php]<?php
    $con = mysql_connect(" localhost","roo t","sreeni") ;
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db ("my_db1", $con);
    // Find out about latest image
    $result = mysql_query("SE LECT * FROM pix1");
    if ($row = @mysql_fetch_as soc($result)) {
    $bytes = $row[upload];

    } else {
    $errmsg = "There is no image in the database yet";
    $title = "no database image available";
    // Put up a picture of our training centre
    $instr = fopen("latest.i mg","rb");
    $bytes = fread($instr,fi lesize("latest. img"));
    }

    // If this is the image request, send out the image

    if ($_REQUEST[gim] == 1) {
    header("Content-type: image/jpeg");
    print $bytes;
    exit ();
    }

    echo "<table border='1'>
    <tr>
    <th>Photo</th>
    <th>name</th>
    <th>email</th>
    <th>location</th>
    <th>message</th>
    </tr>";
    while($row = mysql_fetch_arr ay($result))
    {
    echo "<tr>";
    echo "<td>
    <img src=?gim=1 width=150 height=100>
    <b><?= $title ?>
    </td>";
    echo "<td>" . $row['name'] . "</td>";
    echo "<td>" . $row['email'] . "</td>";
    echo "<td>" . $row['location'] . "</td>";
    echo "<td>" . $row['message'] . "</td>";
    echo "</tr>";
    }
    echo "</table>";
    mysql_close($co n);
    ?>[/php]
    Last edited by ronverdonk; Mar 8 '08, 01:32 PM. Reason: code tags
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    This is the second time (plus PM) I ask you to enclose any code within the appropriate code tags! If you do not want to do this for yourself, then do it to show some respect to the members who are here to help you.

    By repeatedly not complying to the Posting Guidelines, you run the risk of a ban from this forum.

    moderator

    Comment

    Working...