Page 1 of 1

image gallery image not displaying

Posted: Tue May 12, 2009 11:00 pm
by angelic_devil
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

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
Parse error: parse error, expecting `','' or `';'' in D:\wamp\www\php_stockphotos\images_gallery.php on line 63
plz tell me what it is i can tfigure it out also if my code is right for wat i m trying to achieve

Re: image gallery image not displaying

Posted: Wed May 13, 2009 6:35 am
by Defiline

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].'">';
}
?>

Re: image gallery image not displaying

Posted: Wed May 13, 2009 8:33 am
by angelic_devil
the code u mentioned is not working still giving error however of parse however i figured it out.

now the browser displays the location of the php file on the browser like

http://localhost/test1.php can anyone tell me y its displaying the location of php and not the image file?

Re: image gallery image not displaying

Posted: Wed May 13, 2009 1:09 pm
by Benjamin
Forum Rules wrote: 11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.
You may also want to read:
  1. General Posting Guidelines
  2. Posting Code in the Forums
  3. PHP Manual
  4. PHP Tutorials

Re: image gallery image not displaying

Posted: Thu May 14, 2009 2:22 am
by angelic_devil
is there anyone who can help me out with this?

Re: image gallery image not displaying

Posted: Tue May 19, 2009 1:17 am
by angelic_devil
since i tried echoing the $width & $height and it shows error

No such file or directory in D:\wamp\www\images\test3.php

plz tell me where i m going wrong

the directory with images is chmod to 777