i though i should try again.. i tring to display all the images of user who is loged in. my database called image: which has
image_id
user_id
image(type long blob)(stores image here)
image_full_name
---etc
i have two files gallery.php where iam trying to display the images and it uses a image.php file.
i am getting these two error with i dont know how to fix them.
Notice: Undefined index: id in C:\xampp\htdocs\login_test\image.php on line 4
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\login_test\image.php on line 7
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;
}
?>
gallary.php=====================================================================================================
<?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/>";
}
?>