Syntax error

Urgent help needed. Keep getting an unexpected T_STRING error on the following line of code.

[php]$mysock = getimagesize(’…/…/…/images/’ $mainpct);[/php]

$mainpct is a predefined image name. How do I get the syntax right?

You probably already figured this out - missing dot (concatenation operator) in front of $mainpct

Howzit,

I’ve tried this code:

[php]$mysock = getimagesize(’…/images/’ . $mainpct);[/php]

But for some reason I still get the error:

warning: getimagesize(…/images/1319635084.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/wtgsacoz/public_html/wthsa/includes/common.inc(1696) : eval()'d code on line 34.

Which I don’t understand cause the image is definitely saved in the images as the name that comes up in the error, in the file that comes up in the error >:(

A little frustrating… What I’m trying to do with this function is resize an image before it is displayed on page. So the actual image stored as “1319635084.jpg” is large in dimension, but I am resizing it before it is displayed.

This is the function:

[php]function imageResize($width, $height, $target) {
if ($width > $height) {
$percentage = ($target / $width);
} else {
$percentage = ($target / $height);
}
$width = round($width * $percentage);
$height = round($height * $percentage);
return “width=’” . $width . “’ height=’” . $height . “’”;
}

$mainpct = $row[‘mainpct’];

$mysock = getimagesize(’…/images/’ . $mainpct);

echo “

<img src=’…/images/” . $row[‘mainpct’] . “’” . imageResize($mysock[0],$mysock[1], 150) . " />
";[/php]

I’ve left out the SELECT that calls the image name (unimportant).

But these are the errors I get for the whole thing:

warning: getimagesize(…/images/1319635084.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/wtgsacoz/public_html/wthsa/includes/common.inc(1696) : eval()'d code on line 34.

warning: Division by zero in /home/wtgsacoz/public_html/wthsa/includes/common.inc(1696) : eval()'d code on line 17.

Line 17 is “$percentage = ($target / $height);”

um… huh?

Sponsor our Newsletter | Privacy Policy | Terms of Service