Question
Dynamic thumbnails
I am relatively new to PHP and I am working on a project that
uses various
sizes of pictures and I want to create a thumbnails of these image. The
references to these images are held in a database and I have found some code
that uses getimagesize to get the size of the image I can get this to work
if I reference and image directly my problem is I'm having a difficult time
understanding the PHP code to pull the image from the database. I have tried
various methods with the current code that pulls images for display but I
keep getting syntax errors and I really do not know what to do differently
below is a copy of the code than I am using the code was developed in dream
weaver for accessing the database. Any help would be greatly appreciated.
The error I get is Line 76 is the line with the pointer to the image name
in the database.
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
C:\Accounts\antiques\wwwRoot\TestSite\Untitled-2.php on line 76
I am sure that it is probably something really stupid that I am over
looking
Thanks for your help
<body>
<p><img src="../AAAIMAGES/<?php echo $row_Recordset1['Image']; ?>.jpg"
width="235" height="225" /> This displays the mage from the DB</p>
<p> </p>
<p> </p>
<p> </p>
<p><img src="../AAAIMAGES/b151.jpg" /> This displays the image in thumbnail
when I point to the image directly
<?php
$image = "..\AAAIMAGES\b151.jpg";
echo $image;
$size = getimagesize("$image");
$height = $size[1];
$width = $size[0];
if ($height > 150)
{
$height = 200;
$percent = ($size[1] / $height);
$width = ($size[0] / $percent);
}
else if ($width > 150)
{
$width = 200;
$percent = ($size[0] / $width);
$height = ($size[1] / $percent);
}
echo "<img src =\"../AAAIMAGES/b151.jpg\" height=\"$height\"
width=\"$width\" />";
?>
<p><img src="../AAAIMAGES/b151.jpg" /> This displays the image
<?php
// line 76 is below
$image = "../AAAIMAGES/<?php echo $row_Recordset1['Image']; ?>.jpg";
echo $image;
$size = getimagesize("$image");
$height = $size[1];
$width = $size[0];
if ($height > 150)
{
$height = 200;
$percent = ($size[1] / $height);
$width = ($size[0] / $percent);
}
else if ($width > 150)
{
$width = 200;
$percent = ($size[0] / $width);
$height = ($size[1] / $percent);
}
echo "<img src ="../AAAIMAGES/<?php echo $row_Recordset1['Image'];
?>.jpg" height=\"$height\" width=\"$width\" />";
?>
sizes of pictures and I want to create a thumbnails of these image. The
references to these images are held in a database and I have found some code
that uses getimagesize to get the size of the image I can get this to work
if I reference and image directly my problem is I'm having a difficult time
understanding the PHP code to pull the image from the database. I have tried
various methods with the current code that pulls images for display but I
keep getting syntax errors and I really do not know what to do differently
below is a copy of the code than I am using the code was developed in dream
weaver for accessing the database. Any help would be greatly appreciated.
The error I get is Line 76 is the line with the pointer to the image name
in the database.
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
C:\Accounts\antiques\wwwRoot\TestSite\Untitled-2.php on line 76
I am sure that it is probably something really stupid that I am over
looking
Thanks for your help
<body>
<p><img src="../AAAIMAGES/<?php echo $row_Recordset1['Image']; ?>.jpg"
width="235" height="225" /> This displays the mage from the DB</p>
<p> </p>
<p> </p>
<p> </p>
<p><img src="../AAAIMAGES/b151.jpg" /> This displays the image in thumbnail
when I point to the image directly
<?php
$image = "..\AAAIMAGES\b151.jpg";
echo $image;
$size = getimagesize("$image");
$height = $size[1];
$width = $size[0];
if ($height > 150)
{
$height = 200;
$percent = ($size[1] / $height);
$width = ($size[0] / $percent);
}
else if ($width > 150)
{
$width = 200;
$percent = ($size[0] / $width);
$height = ($size[1] / $percent);
}
echo "<img src =\"../AAAIMAGES/b151.jpg\" height=\"$height\"
width=\"$width\" />";
?>
<p><img src="../AAAIMAGES/b151.jpg" /> This displays the image
<?php
// line 76 is below
$image = "../AAAIMAGES/<?php echo $row_Recordset1['Image']; ?>.jpg";
echo $image;
$size = getimagesize("$image");
$height = $size[1];
$width = $size[0];
if ($height > 150)
{
$height = 200;
$percent = ($size[1] / $height);
$width = ($size[0] / $percent);
}
else if ($width > 150)
{
$width = 200;
$percent = ($size[0] / $width);
$height = ($size[1] / $percent);
}
echo "<img src ="../AAAIMAGES/<?php echo $row_Recordset1['Image'];
?>.jpg" height=\"$height\" width=\"$width\" />";
?>
