Page 1 of 1

parse errors on my first script, can you help plz? :)

Posted: Thu May 23, 2002 12:45 am
by MoneyD
hey all, i'm a PHP newbie, but thanks to the NewbieNetwork, i've gotten off to what i thought was a good start, atleast till i tested my script, lol.
i'm gettin a parse error (specifically at line 45) and i haven't been able to figure out what that means. so any help would be greatly appreciated.
here's the code

Code: Select all

<html>
	<head>
		<title>
			PHP-Database Photo Album
		</title>
		<script language="javascript" src="photo_popup.js">
		</script>
	</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#0000ff" alink="#0000ff">

<!--Begin Image Display Table-->
<table width="75%" cellpadding="2" cellspacing="0" align="center" border="0">

<!--Begin PHP Coding for Image Gallery-->
<?PHP

//set variables
$data_file = "/full_size/list.php";
$thumbs_dir = "thumbs/";
$num_rows = "2";
$pic_per_row = "3";
$photos = file($data_file);
$total_photos = sizeof($photos);
$photos_per_page = $rows * $pic_per_row;

//if not set, set to 0 and start at beginning of gallery
if(!isSet($start))&#123;
	$start = 0;
&#125;

//set i equal to where to start in photo array
$i = $start;
$next_start = $start - $photos_per_page;
$prev_start = $start + $photos_per_page;

//begin printing of table to hold image thumbnails
for ($row=0; $row < $num_rows; $row++)&#123;
	echo ("<tr>\n");
	for ($col=0; $col < $pic_per_row; $col++)&#123;
		if ($i < $total_photos)&#123;
			$thumbnail = $thumbs_dir.trim($photos&#1111;$i]);
			$thumb_image_size = getimagesize(thumbnail);
			$image_size = getimagesize(trim($photos&#1111;$i]));
				echo ("<td align="center">
				<a href="javascript:photo_open('photo_display.php?photo=".trim($photos&#1111;$i]."','"$image_size&#1111;0]."','"$image_size&#1111;1]."');">
				<img src="".$thumbnail."" ".thumb_image_size&#1111;3].">
				</a>
				</td>\n");
		&#125; else &#123;
			echo ("<td></td>\n");
		&#125;
		$i++;
	&#125;
	echo ("</tr>\n");
&#125;

//end table insert
?>
<!--End PHP Coding for Image Gallery-->

</table>

<!--Begin PHP Coding for Image Gallery Navigation-->
	<div align="center">
<?PHP
//Print out Navigation Links
if(($start == 0) && ($next_start < $total_photos))&#123;
//At beginning of Gallery
?>
	<span style="font-family:arial; font-size: 12px; font-weight: bold;>
		<a href="photo_index.php?start=<?PHP echo($next_start);?>">Next Page</a>
	</span>
<?PHP
&#125;
elseif (($start > 0) && ($next_start < $total_photos))&#123;
//In Middle of Gallery
?>
	<span style="font-family:arial; font-size: 12px; font-weight: bold;>
		<a href="photo_index.php?start=<?PHP echo($prev_start);?>">Previous Page</a>
		|
		<a href="photo_index.php?start=<?PHP echo($next_start);?>">Next Page</a>
	</span>
<?PHP
&#125;
elseif (($start == 0) && ($next_start > $total_photos))&#123;
//In a One-Page Gallery
?>

<?PHP
&#125;
else &#123;
//At the end of the Gallery
?>
	<span style="font-family:arial; font-size: 12px; font-weight: bold;>
		<a href="photo_index.php?start=<?PHP echo($prev_start);?>">Previous Page</a>
	</span>
<?PHP
&#125;
?>
	</div>
<!--End PHP Coding for Image Gallery Navigation-->

</body>
</html>
sorry it's so long, but i'm not sure what the problem is exactly, so i figured i should include the whole thing. thanks in advance!!
lata on,
Money

Posted: Thu May 23, 2002 3:23 am
by mikeq
First thing get yourself a PHP editor, I use PHPEdit it is free http://www.phpedit.com

Okay,

using this tool it highlights your opening bracket on line 44

Code: Select all

&lt;?php
            echo ("&lt;td align="center"&gt; 
            &lt;a href="javascript:photo_open('photo_display.php?photo=".trim($photos&#1111;$i]."','"$image_size&#1111;0]."','"$image_size&#1111;1]."');"&gt; 
            &lt;img src="".$thumbnail."" ".thumb_image_size&#1111;3]."&gt; 
            &lt;/a&gt; 
            &lt;/td&gt;\n");
?&gt;
It highlights it because there is no closing bracket, but you might think there is, it's on line 48, isn't it. Nope, if you look at your trim function on line 45 you will see there is no closing ) therefore it thinks the ) on line 48 is the closing bracket for the trim function and that the echo function does not have a closing bracket, tadaa :D

I suggest you download this editor, it took a couple of minutes to resolve this using PHPEdit, and whilst people on this forum don't mind helping out these issues could be solved easily by yourself.

Most of the time when the parser gives a line as an error it is usually the line before it that has the error, in this case line 44 had an opening ( but nowhere did it have a closing )

Regards
Mike

Posted: Thu May 23, 2002 6:00 am
by MoneyD
yeah, thankyou very much for the help. I actually found a few things missing from the code, and i'm on my way to dl PHPEdit, so i don't hassle peepz with dumb questions again.
Thanks though, as i had no idea that editors where available :D

well, back to work i go :D
thanks again.
if i get stumped on a lil more advanced issue, lol, i'll be back for more help ;)

lata on,
Money