Why am i getting an error at the start of my nested if code?
<?php
function thumb($source, $quality = 80)
{
/* Check for the image's exisitance */
if (!file_exists($source)) {
echo 'File does not exist!';
}
else {
$size = getimagesize($source); // Get the image dimensions and mime type
$oldwidth = '$size[0]'; // Width divided
$oldheight = '$size[1]'; // Height divided
# taller
if ('$oldheight' > '$oldwidth') {
$w = ('$oldwidth' / '$oldheight') * '150';
$h = '150';
}
# wider
else if ('$oldwidth' > '$oldheight') {
$h = ('$oldheight' / '$oldwidth') * '150';
$w = '150';
}
# equal
else ('$oldwidth' = '$oldheight') {
$h = '150';
$w = '150';
}
$resize = imagecreatetruecolor($w, $h); // Create a blank image
/* Check quality option. If quality is greater than 100, return error */
if ($quality > 100) {
echo 'The maximum quality is 100. <br>Quality changes only affect JPEG images.';
}
else {
header('Content-Type: '.$size['mime']); // Set the mime type for the image
switch ($size['mime']) {
case 'image/jpeg':
$im = imagecreatefromjpeg($source);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); // Resample the original JPEG
imagejpeg($resize, '', $quality); // Output the new JPEG
break;
case 'image/png':
$im = imagecreatefrompng($source);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); // Resample the original PNG
imagepng($resize, '', $quality); // Output the new PNG
break;
}
imagedestroy($im);
}
}
}
thumb($_GET['source'], $_GET['quality']);
?>
<?php
function thumb($source, $quality = 80)
{
/* Check for the image's exisitance */
if (!file_exists($source)) {
echo 'File does not exist!';
}
else {
$size = getimagesize($source); // Get the image dimensions and mime type
$oldwidth = '$size[0]'; // Width divided
$oldheight = '$size[1]'; // Height divided
# taller
if ('$oldheight' > '$oldwidth') {
$w = ('$oldwidth' / '$oldheight') * '150';
$h = '150';
}
# wider
else if ('$oldwidth' > '$oldheight') {
$h = ('$oldheight' / '$oldwidth') * '150';
$w = '150';
}
# equal
else ('$oldwidth' = '$oldheight') {
$h = '150';
$w = '150';
}
$resize = imagecreatetruecolor($w, $h); // Create a blank image
/* Check quality option. If quality is greater than 100, return error */
if ($quality > 100) {
echo 'The maximum quality is 100. <br>Quality changes only affect JPEG images.';
}
else {
header('Content-Type: '.$size['mime']); // Set the mime type for the image
switch ($size['mime']) {
case 'image/jpeg':
$im = imagecreatefromjpeg($source);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); // Resample the original JPEG
imagejpeg($resize, '', $quality); // Output the new JPEG
break;
case 'image/png':
$im = imagecreatefrompng($source);
imagecopyresampled($resize, $im, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); // Resample the original PNG
imagepng($resize, '', $quality); // Output the new PNG
break;
}
imagedestroy($im);
}
}
}
thumb($_GET['source'], $_GET['quality']);
?>