ok so iam trying to fix this for about 7 weeks now. and no one seem to now what is wrong with it.
all i want to do is to print all images of user who is loged in. image store in database type long blob.
problem is that it prints broken links
gallery.php ---where i want to display all the images.
<?php
session_start();
include("connect.php");
$user = $_SESSION['username'];
$id = $_SESSION['user_id']; //get user_id who ever is loged in
if($user) //is user is loged in
{
//select images from database
$sql = "SELECT * FROM image WHERE user_id = $id ORDER BY image_id DESC";
$result = mysql_query($sql);
/*** table which holds images ***/
echo "your gallery<br/><br/><br/>";
echo "<a href='upload.php'>upload image</a>";
echo "<table>"; // Your table
echo "<tr>"; // first table row
$count = 0;
while($row = mysql_fetch_assoc($result))
{
echo '
<td>
<img src="image.php?id='.$row['image_id'].'" />
</td>
';
$count++;
if($count == 5) //6 rows
{
echo "</tr><tr>"; // Start a new row at 6 cells
$count = 0;
}
}
echo "</tr>";
echo "</table>";
echo "<a href='index.php'>home</a><br/><br/><br/>";
}
?>
image.php
<?php
session_start();
include("connect.php");
$id = $_GET['id'];
$sql = "SELECT image FROM image WHERE image_id = $id";
$result = mysql_query($sql);
if ($row = mysql_fetch_assoc($result)) //should only be one record
{
$imgdata = base64_decode($row[image]);
header("Content-Type: image/jpeg");
header("Content-Length: ".strlen($imgdata));
echo $imgdata;
}
?>