开发者

Unexpected $end: I Know exactly where the culprit is, but don't know how to fix it

I get this error message:

"Parse error: syntax error, unexpected $end in C:\Users\Stacky\Desktop\xampp\htdocs\wweff\stackhelp.php on line 822"

I've been trying to get this code working by tinkering with only one line of my code, line 54.

Here's the full code. Look out for "//^^^^ RIGHT ABOVE IS LINE 54." in the code below:

<html>
<head>
</head>
<body>
    <?php
        $objConnect = mysql_connect("localhost","root","") or die(mysql_error());
        $objDB = mysql_select_db("thegoodhumor");
        $strSQL = "SELECT * FROM gallery";
        if (!isset($_GET['Page']))  $_GET['Page']='0';
        $objQuery = mysql_query($strSQL);
        $Num_Rows = mysql_num_rows($objQuery);
        $Per_Page = 16;   // Per Page

        $Page = $_GET["Page"];
        if(!$_GET["Page"])
        {
            $Page=1;
        }

        $Prev_Page = $Page-1;
        $Next_Page = $Page+1;

        $Page_Start = (($Per_Page*$Page)-$Per_Page);
        if($Num_Rows<=$Per_Page)
        {
            $Num_Pages =1;
        }
        else if(($Num_Rows % $Per_Page)==0)
        {
            $Num_Pages =($Num_Rows/$Per_Page) ;
        }
        else
        {
            $Num_Pages =($Num_Rows/$Per_Page)+1;
            $Num_Pages = (int)$Num_Pages;
        }

   开发者_如何学编程     $strSQL .=" order  by GalleryID ASC LIMIT $Page_Start , $Per_Page";
        $objQuery  = mysql_query($strSQL);
                $cell = 0;
                echo '<table border="1" cellpadding="2" cellspacing="1"><tr>';
                while($objResult = mysql_fetch_array($objQuery))
                {
                  if($cell % 4 == 0) {
                  echo '</tr><tr>';
                }

                if($cell == 2 || $cell == 3) {
                echo '<td>RESERVED</td>';
                } else {
                echo '<td><img src="https://s3.amazonaws.com/imagetitle/' .  
                $objResult["Picture"];?>" height="190" width="190" /> . .$objResult["GalleryName"].'\</td>';
                //^^^^ RIGHT ABOVE IS LINE 54.
                }
                $cell++;
                }
                echo '</tr></table>';
    ?>
        <?php
          //DELETED PAGINATION CODE for the sake of simplicity in StackOverflow
        ?>
        </body>
        </html>
        <?php
        mysql_close($objConnect);
        ?>


        $objResult["Picture"];?>" height="190" width="190" /> . .$objResult["GalleryName"].'\</td>';

Contains ?>, which tells the PHP interpreter to stop interpreting, in other words everything that follows is raw HTML.

Try changing the ;?> to a ., putting a ` before height="190", and remove the \ before </td>, giving:

        $objResult["Picture"] . 'height="190" width="190" />' .
            $objResult["GalleryName"] . '</td>';


You have "?>" in the middle of line 54, which tells PHP to stop pre-processing (in the middle of your echo statement). You probably want to remove that.


In the following portion of code :

while($objResult = mysql_fetch_array($objQuery))
{
  if($cell % 4 == 0) { // A { is opened here
  echo '</tr><tr>';
  // Maybe it should be closed here ?
}

It seems you are not closing the { that corresponds to the if.


And, a bit lower in your code, you have a } that doesn't seem to belong there :

if($cell == 2 || $cell == 3) {
    echo '<td>RESERVED</td>';
} else {
    echo '<td><img src="https://s3.amazonaws.com/imagetitle/' .  
    $objResult["Picture"];?>" height="190" width="190" /> . .$objResult["GalleryName"].'\</td>';
    //^^^^ RIGHT ABOVE IS LINE 54.
} // closing the else
$cell++;
} // what is this doing here ?


General advice in this kind of situation : indent your code properly !

This will allow you to catch this kind of problems far more easily ;-)
And will make your code easier to read, of course.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜