7 Replies - 787 Views - Last Post: 20 February 2012 - 10:17 AM Rate Topic: -----

#1 KiNgY   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 07-March 08

syntax error, unexpected '}'

Posted 20 February 2012 - 09:01 AM

Hey guys well I have this error and i have no idea why? I am guessing it has something to do with the $counter++ anyway i wonder if anybody can see the syntax error and explain to me what is wrong here is the error message:

Parse error: syntax error, unexpected '}' in /home/a2321317/public_html/change_gallery.php on line 77

And here is my code:

<?PHP

SESSION_START();
INCLUDE("function/login_check.php");
INCLUDE("database/connect.php");

?>
<HTML>
<HEAD>
<TITLE>Admin - Change Gallery</TITLE>
</HEAD>
<BODY>
<LINK HREF="style/upload.css" REL="stylesheet" TYPE="text/css">
<FORM ACTION="upload_process.php" METHOD="post" ENCTYPE="multipart/form-data">

<TABLE CLASS="wrap" ALIGN="center">
 <TR>
  <TD>
   <TABLE CLASS="border2" CELLSPACING="0" CELLPADDING="0" ALIGN="center">
    <TR>
     <TD CLASS="top_left"></TD><TD CLASS="top"></TD><TD CLASS="top_right"></TD>
    </TR>
    <TR>
     <TD CLASS="left"></TD><TD CLASS="main">
      <TABLE CLASS="main">
       <TR>
        <TD CLASS="header" COLSPAN="50">Admin - Edit Gallery</TD>
       </TR>
       <TR>
        <TD CLASS="sub_header" COLSPAN="50">Please select the gallery to edit.</TD>
       </TR>
       <TR>
<?PHP

 $found = "no";
 $query = "SELECT * FROM album_list";
 $result = MYSQL_QUERY($query);
 $counter = 0;

 WHILE ($row = MYSQL_FETCH_ASSOC($result)) {

  $album = "album" . $row["album_id"];
  $select = "SELECT * FROM $album";
  $done = MYSQL_QUERY($select);
  $counter++;

  IF (mysql_num_rows($done) >= 1) {

   WHILE ($info = MYSQL_FETCH_ASSOC($done)) {

    $value = $info["img_thumbnail"];
    $temp = $info["img_location"];

    IF ($value == 1){

     $thumbnail = $temp;
     $found = "yes";
     $value = "0";

    }
   }

   IF ($found == "yes") {

    echo "<td class=\"main\"><img src=\"thumbnail/200/$thumbnail\"><br>".$row["album_name"]."</td>";
    $found = "no";

   } ELSE {

    echo "<td class=\"main\">".$row["album_name"]."<br>no thumbnail</td>";

   }
  } ELSE {

   echo "<td class=\"main\">".$row["album_name"]."<br>no images</td>";

  }

  IF ($counter == "3") {
  echo "</TR><TR>";
  $counter == 0;
  }
 }


?>
       </TR>
       <TR>
        <TD CLASS="align_right" COLSPAN="50"><a class="sub" href="main.php">Admin Home</a></TD>
       </TR>
      </TABLE></TD><TD CLASS="right"></TD>
    </TR>
    <TR>
     <TD CLASS="bottom_left"></TD><TD CLASS="bottom"></TD><TD CLASS="bottom_right"></TD>
    </TR>
   </TABLE>
  </TD>
 </TR>
</TABLE>

</FORM>
</BODY>
</HTML>



Here's hoping somebody can help ~ KiNgY!

Is This A Good Question/Topic? 0
  • +

Replies To: syntax error, unexpected '}'

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15804
  • View blog
  • Posts: 63,309
  • Joined: 12-June 08

Re: syntax error, unexpected '}'

Posted 20 February 2012 - 09:14 AM

Line 72 - it looks like you have an extra "}" thrown in there..
Was This Post Helpful? 0
  • +
  • -

#3 KiNgY   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 07-March 08

Re: syntax error, unexpected '}'

Posted 20 February 2012 - 09:19 AM

I know but when i check it everything is opened and closed properly :/ I think it is just me but i cant see where i have put the extra } :S
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6877
  • View blog
  • Posts: 31,672
  • Joined: 10-May 07

Re: syntax error, unexpected '}'

Posted 20 February 2012 - 09:30 AM

Line 72 ends a while statement, you can't have an else on a while statement.

My suggestion is that these would be easier to read if you properly intended & did the following :

 if () {
 }
 else {
 }


Was This Post Helpful? 0
  • +
  • -

#5 KiNgY   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 07-March 08

Re: syntax error, unexpected '}'

Posted 20 February 2012 - 09:37 AM

I'm not too sure, doesn't line 72 end the IF statement started on line 63 and then the line 73 is ending and then starting an ELSE from the IF statement started on line 47 :/ thats the way i read it as I dont read it as line 72 as ending a while. I am sorry if it is me completely looking at this wrong but i am very confused and am greatly appreciative of your help. I will take onboard what you have said about indenting, would you like me to indent it as you said and then re-post?
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15804
  • View blog
  • Posts: 63,309
  • Joined: 12-June 08

Re: syntax error, unexpected '}'

Posted 20 February 2012 - 09:43 AM

What do you mean you guess? Track the brackets!

 WHILE ($row = MYSQL_FETCH_ASSOC($result)) 
{ -- 1

  IF (mysql_num_rows($done) >= 1) 
{ -- 2

   WHILE ($info = MYSQL_FETCH_ASSOC($done)) 
{ -- 3

    IF ($value == 1)
{ -- 4
} -- /4
   } -- /3

   IF ($found == "yes") 
{ -- 5
   }  -- /5
ELSE 
{ -- 6

   } -- /6
  }  -- /2  -------- you are trying to close the if statement and append an else to it?  

ELSE 
{ -- 7


 } -- /7

{ -- 8
  } -- / 8
 } -- / 1


Was This Post Helpful? 0
  • +
  • -

#7 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6877
  • View blog
  • Posts: 31,672
  • Joined: 10-May 07

Re: syntax error, unexpected '}'

Posted 20 February 2012 - 09:50 AM

I did what modi123_1 did, I just didn't post it.
Was This Post Helpful? 1
  • +
  • -

#8 KiNgY   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 07-March 08

Re: syntax error, unexpected '}'

Posted 20 February 2012 - 10:17 AM

I just tried what the method you showed me to check the syntax (I will remember that to check syntax in the future, Thank You!) and it followed through properly, it all closes in the right places and i have else's in all the right places :S I really don't get this, sorry guys! :(

Yes I am trying to end the IF statement at #2 and then start an ELSE from it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1