Jump to content

[SOLVED] Parse error: syntax error, unexpected ')'


RyanSF07

Recommended Posts

Hi All,

 

I'm getting a "Parse error: syntax error, unexpected ')'  on line 28" error that I need help unwinding. I've tried several combinations of quotes and single quotes without any luck. Needs fresh eyes. Could you please have a look and offer suggestions? I've left it plain here...

 

line 28 is this:

$resized= getimagesize(uploaded_files/$info['photo'].); 

 

And the full script is:

 

<?php

include_once ("connect.php");

$data = mysql_query("SELECT * FROM cars") or die(mysql_error());

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\"";

}

$resized= getimagesize(uploaded_files/$info['photo'].); 

while($info = mysql_fetch_array( $data ))
{

Echo "<img src=http://www.website/uploaded_files/".$info['photo']." imageResize($resized[0],  
$resized[1], 150);> <br>";
Echo "<b>Make:</b> ".$info['make'] . "<br> ";
Echo "<b>Model:</b> ".$info['model'] . " <br>";
Echo "<b>Year:</b> ".$info['year'] . " <hr>";
}
?> 

 

 

Thank you in advanced for your help!

 

Link to comment
Share on other sites

Thank you for the quick reply Prismatic! That did fix the error.

 

The script is finding all of the images in the folder, however, images that are larger than 150px are not being displayed.

 

I think now the problem is here:

Echo "<img src=http://www.website/uploaded_files/".$info['photo']." imageResize($resized[0],  
$resized[1], 150);> <br>";

 

The imageResize function isn't running. I've tried adding php tags on either side and get a syntax error.

 

I know that this isn't right (snip below) --as it returns and extra >  --- could you please proof this and offer suggestions?:

Echo "<img src=http://www.website/uploaded_files/".$info['photo']." <? imageResize($resized[0],  
$resized[1], 150);?>> <br>";

 

Thanks!!

Link to comment
Share on other sites

Thank you again, Prismatic. That worked.

 

There is something wrong though that I have to figure out. If you have any ideas, please let me know -- though -- thank you very much for the help you've already provided!

 

I'm getting this error:

Warning: Division by zero in view.php on line 16

 

Line 16 is:

$percentage = ($target / $height);

 

 

Link to comment
Share on other sites

I added one, and got the same results.

 

The images are in the uploaded_files folder, but the name of the images are stored in the database.

 

I think the images are in fact being selected, but the resize function is breaking thus the images don't display.

 

trying a couple different things --- all suggestions welcome.

 

Thank you guys!

Link to comment
Share on other sites

Thank you for your help, Ken.

 

Now only one item is selected from the database instead of the resize function being applied to all images -- and frustratingly so -- the actual image is not displayed, just the "image-broken" box.

 

echoing resized[0] and resized[1] now produces: 1

 

what do you think? scrap this and start over? If you have other ideas please let me know as I'm running out  :P

 

I have this now:

<?php

include_once ("connect.php");

$data = mysql_query("SELECT * FROM cars") or die(mysql_error());

function imageResize($width, $height, $target) {

if ($width > $height) {
$percentage = ($target / $width);
} else {
$percentage = $height == 0? 0 : $target / $height;
}

$width = round($width * $percentage);
$height = round($height * $percentage);

return "width=\"$width\" height=\"$height\"";

}

while($info = mysql_fetch_array( $data ))
$resized= getimagesize("uploaded_files/". $info['photo']);
{

echo "<img src='http://www.website/uploaded_files/". $info['photo'] ."'" . imageResize($resized[0], $resized[1], 150) ."> <br>";
Echo "<b>Make:</b> ".$info['make'] . "<br> ";
Echo "<b>Model:</b> ".$info['model'] . " <br>";
Echo "<b>Year:</b> ".$info['year'] . " <hr>";
}
echo $resized[0] and $resized[1];
?>

 

Link to comment
Share on other sites

Syntax much?

 

<?php

include_once ("connect.php");

$data = mysql_query("SELECT * FROM cars") or die(mysql_error());

function imageResize($width, $height, $target) {

if ($width > $height) {
$percentage = ($target / $width);
} else {
$percentage = $height == 0? 0 : $target / $height;
}

$width = round($width * $percentage);
$height = round($height * $percentage);
return "width=\"$width\" height=\"$height\"";
}

while($info = mysql_fetch_array( $data )) {
$resized= getimagesize("uploaded_files/". $info['photo']);
echo "<img src='http://www.website/uploaded_files/". $info['photo'] ."' " . imageResize($resized[0], $resized[1], 150) ."> <br>";
echo "<b>Make:</b> ".$info['make'] . "<br> ";
echo "<b>Model:</b> ".$info['model'] . " <br>";
echo "<b>Year:</b> ".$info['year'] . " <hr>";
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.