RyanSF07 Posted April 30, 2009 Share Posted April 30, 2009 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 https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/ Share on other sites More sharing options...
Prismatic Posted April 30, 2009 Share Posted April 30, 2009 <?php $resized= getimagesize("uploaded_files/". $info['photo']); ?> Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822741 Share on other sites More sharing options...
RyanSF07 Posted April 30, 2009 Author Share Posted April 30, 2009 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 https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822758 Share on other sites More sharing options...
Prismatic Posted April 30, 2009 Share Posted April 30, 2009 Try this <?php echo "<img src='http://www.website/uploaded_files/". $info['photo'] ."'". imageResize($resized[0], $resized[1], 150) ."> <br>"; ?> Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822764 Share on other sites More sharing options...
RyanSF07 Posted April 30, 2009 Author Share Posted April 30, 2009 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 https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822800 Share on other sites More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 $percentage = $height == 0? 0 : $target / $height; Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822803 Share on other sites More sharing options...
RyanSF07 Posted April 30, 2009 Author Share Posted April 30, 2009 Thanks Ken -- That fixed the error -- but now no images at all display Jeeze what a script! Thanks for your help! -- almost there Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822824 Share on other sites More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 Should there be a space after the single quote that closed out the src attr of img? Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822832 Share on other sites More sharing options...
RyanSF07 Posted April 30, 2009 Author Share Posted April 30, 2009 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 https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822842 Share on other sites More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 What do you get if you echo $resized[0] and $resized[1]? Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822853 Share on other sites More sharing options...
RyanSF07 Posted April 30, 2009 Author Share Posted April 30, 2009 nothing shows up I don't know -- maybe not connecting to that folder Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822873 Share on other sites More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 Oh, $info isn't defined at that point. It's defined in the while loop after it. that's why. Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822879 Share on other sites More sharing options...
RyanSF07 Posted April 30, 2009 Author Share Posted April 30, 2009 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 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 https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822893 Share on other sites More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 Can you post the code you have thus far? It's confusing with so many changes done to it to keep track of what your script looks like now. Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822895 Share on other sites More sharing options...
RyanSF07 Posted April 30, 2009 Author Share Posted April 30, 2009 yes -- I modified the previous post to include it. Thank you! Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822898 Share on other sites More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 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 https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822901 Share on other sites More sharing options...
RyanSF07 Posted April 30, 2009 Author Share Posted April 30, 2009 rusty -- very rusty -- and was never very good at this to begin with. Thank you so much for your help. Solved. Ryan Link to comment https://forums.phpfreaks.com/topic/156281-solved-parse-error-syntax-error-unexpected/#findComment-822913 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.