image gallery image not displaying
Posted: Tue May 12, 2009 11:00 pm
i have a folder on the server and images already uploaded to that folder....the link to the folder is stored database in table - usersfolder under field- image-path.
now i m trying to get the browser to read the path from image_path and resize the image as thumbnail and display it on the browser.
but i m getting a blank page
here is my code
error i m getting is
now i m trying to get the browser to read the path from image_path and resize the image as thumbnail and display it on the browser.
but i m getting a blank page
here is my code
Code: Select all
<?php
// Database Constants
define("DB_SERVER", "localhost");
define("DB_USER", "lucky");
define("DB_PASS", "lucky");
define("DB_NAME", "stockphotos");
?>
<?php
// 1. Create a database connection
$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
if (!$connection) {
die("Database connection failed: " . mysql_error());
}
// 2. Select a database to use
$db_select = mysql_select_db(DB_NAME,$connection);
if (!$db_select) {
die("Database selection failed: " . mysql_error());
}
?>
<?php
// generating a array with image paths
$query_images = "SELECT image_path FROM userfolders" ;
$result_images = mysql_query($query_images);
confirm_query($result_images);
while ($record_images = mysql_fetch_assoc($result_images)) {
$image_list[] = $record_images['image_path'] ;
?>
<?php
// generating a thumbnail
$thumb_height = 100;
for ($i=0;$i<count($image_list);$i++)
{
// Content type
header('Content-type: image/jpeg');
$filename = $image_list[$i];
list($width, $height) = getimagesize($filename);
$ratio = ($height/$width);
$newheight = $thumb_height;
$newwidth = ($thumb_height/$ratio);
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
$thumbnail_rezised[$i] = imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// displaying thumbnail
$thumbnail[$i]= imagejpeg($thumb,$filename);
echo '<img src="'{$thumbnail[$i]}'">';
}
?>
error i m getting is
plz tell me what it is i can tfigure it out also if my code is right for wat i m trying to achieveParse error: parse error, expecting `','' or `';'' in D:\wamp\www\php_stockphotos\images_gallery.php on line 63