Parse error: syntax error, unexpected T_ELSE

Discussion in 'PHP' started by NaSh123, Sep 12, 2008.

  1. #1
    Anyone see anything wrong here? The error is at the line with the code
    "} else {"

    for ($j=1; $j < (ceil($r['total'] / 10) + 1);$j++) {
    if ($pp > 40) { echo "<br />"; $pp= 0; }
    if ($j == ($l / 10)) { echo "<strong>Page " . $j . "</strong>&nbsp;"; }
    else {
    if($j != 1) {
    echo "<a href=\"http://www.site.com/" . $idd . "/" . ($j * 10) . "/\" title=\"" . $idd . " category page " . $j . "\">Page " . $j . "</a>&nbsp;"; }
    } else {
    echo "<a href=\"http://www.site.com/" . $idd . "\" title=\"" . $idd . " category page " . $j . "\">Page " . $j . "</a>&nbsp;"; }
    }
    $pp++;
    }
    Code (markup):
     
    NaSh123, Sep 12, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    You've placed one } on the wrong place

    Please structure your code for better understanding!

    
    <?
    
    for ($j=1; $j < (ceil($r['total'] / 10) + 1);$j++)
    {
        if ($pp > 40) { echo "<br />"; $pp= 0; }
        if ($j == ($l / 10))
        {
            echo "<strong>Page " . $j . "</strong>&nbsp;";
        }
        else
        {
            if($j != 1)
            {
                echo "<a href=\"http://www.site.com/" . $idd . "/" . ($j * 10) . "/\" title=\"" . $idd . " category page " . $j . "\">Page " . $j . "</a>&nbsp;";
            }
            else
            {
                echo "<a href=\"http://www.site.com/" . $idd . "\" title=\"" . $idd . " category page " . $j . "\">Page " . $j . "</a>&nbsp;"; }
            }
        $pp++;
        }
    }
    
    Code (markup):
     
    EricBruggema, Sep 12, 2008 IP
  3. NaSh123

    NaSh123 Peon

    Messages:
    1,298
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Your code still gave an error. I removed the LAST } in your code and now it worked but it still seems weird. i guess as long as it works lol.
     
    NaSh123, Sep 12, 2008 IP