getting a error from a script mod

Discussion in 'PHP' started by irdogg, Mar 16, 2013.

  1. #1
    Parse error: syntax error, unexpected $end in /home/public_html/includes/functions.php on line 2154
    2154 is ?> im confused :oops: help me please line 19-35 is the code thats giving the issue when added i get a blank white screen

    ?>
     
    <table width="200" border="0" align="center" cellpadding="3" cellspacing="0">
    <tr>
        <td colspan="2" align="center"><span class="profileFavoriteGameTitle">Favorite Game</span></td>
        </tr>
      <tr>
              <td width="50" align="center" class="profile"><a href="<?=$favoritelink;?>"><img src="<?=$favoriteicon;?>" alt="Click to play <?=$favoritename;?>" width="25" height="25" border="0" alt="<?=$favoritename;?> Icon"></a></td>
              <td width="150" class="profileFavoriteGame"><a href="<?=$favoritelink;?>"><?=$favoritename;?></a></td>
            </tr>
    </table>
    <?
        }
      }
       
       
    }
     
        function keyword_links($base_url,$rewrite,$keywords){
     
        $sep_keywords = explode(",", $keywords);
        $TotalKeywords = count($sep_keywords);
       
        for($i=0; $i < $TotalKeywords; $i++){
       
        $se_keyword = make_friendly_no_ext(trim($sep_keywords[$i]));
       
        if($rewrite==1)
        $se_keyword_link = $base_url."tags/".$se_keyword.".html";
        else
        $se_keyword_link = $base_url."index.php?action=browse&tag=$se_keyword";
       
        $content.= "<a href=\"$se_keyword_link\">$sep_keywords[$i]</a>";
        if($i < $TotalKeywords-1)
        $content.=", ";
    ?>
    Code (markup):

     
    Solved! View solution.
    irdogg, Mar 16, 2013 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    Add another } before the last ?> and it should work as far as i can see.
     
    EricBruggema, Mar 17, 2013 IP
  3. #3
    add 2 x } before last ?> ex: }} ?>
     
    varcush, Mar 17, 2013 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    Is that the ENTIRE file? The usually cause of that, as others just said, is unclosed/missing closing brackets. If you had some PROPER indentation that might show up more too... if you open a {, TAB IT IN, when you make your close, remove a tab -- that's how you avoid errors like this.

    Of course, that table for nothing is a bit wonky too, since that doesn't appear to be tabular data... and of course the incomplete openings that are no longer considered valid, opening and closing PHP multiple times for christmas only knows what, etc, etc... means there are deeper rooted issues in the code.

    I mean, if I was writing the same thing, it would go something like this:
    echo '
    	<div class="favoriteGame">
    		<h2>Favorite Game</h2>
    		<a href="',$favoritelink,'">
    			<img
    				src="',$favoriteicon;,'"
    				alt="Click to play ',$favoritename,'"
    				width="25" height="25"
    			/>
    			',$favoritename,'
    		</a>
    	<!-- .favoriteGame --></div>';
    	
    function keyword_links($base_url,$rewrite,$keywords){
    	$sep_keywords = explode(",", $keywords);
    	$keyCount = count($sep_keywords);
    	foreach ($sep_keywords as $keyword) {
        $content.= '<a href="'.$base_url.(
    			$rewrite == 1 ?
    			'tags/'.$se_keyword.'.html' :
    			'index.php?action=browse&amp;tag='.$se_keyword
    		).'">'.make_freindly_no_ext(trim($keyword).'</a>'.(
    			--$keyCount ? ', ' : ''
    		);
    	}
    }
    Code (markup):
    Untested/not debugged, might be a typo in there... but really you can see how it 'guts it down' a wee bit.

    Though really since you started out closing php with ?>, it's likely there's a lot in there we're not seeing not just before your snippet, but after it as well. Snippets are cute, but quite often are misleading or don't show the whole picture of exactly what's wrong.
     
    deathshadow, Mar 17, 2013 IP
  5. irdogg

    irdogg Well-Known Member

    Messages:
    358
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    135
    #5
    it was part because there is a limit on data you can add in post here. varcush solved it thank u for the reply deathshadow

     
    irdogg, Mar 17, 2013 IP