Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic thumbnails

LEGEND ,
Jun 22, 2006 Jun 22, 2006
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\" />";
?>



TOPICS
Server side applications
224
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2006 Jun 23, 2006
LATEST
TAD wrote:
> 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 haven't checked the rest of your code but the parse error is caused by
nesting PHP tags within a PHP block. PHP blocks cannot be nested. The
following line

$image = "../AAAIMAGES/<?php echo $row_Recordset1['Image']; ?>.jpg";

should be

$image = "../AAAIMAGES/{$row_Recordset1['Image']}.jpg";

You need to surround $row_Recordset1['Image'] by curly braces to include
this sort of array variable in a double-quoted string.

--
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines