I'm still having problems getting this to work. No matter where/how I put the code in it still says something like "error on line..." and when I check that line it was a code that worked before. 
This is practically the default code, with minor edits for my site. Can you help?
	Code:
	//This function determines what shows in the side bar of the template
	$isloggedin = $GLOBALS['isloggedin'];
	$loggedinname = $GLOBALS['loggedinname'];
	if($isloggedin == "yes") {
		$msgctr = "<a href='messages.php'>Messages</a>";
		
		$stmt = $GLOBALS['adopts']->query("SELECT * FROM {$GLOBALS['prefix']}messages WHERE touser='{$loggedinname}' and status='unread'");
	    $row = $stmt->fetchAll();
		if(count($row) > 0) {
		    $msgctr = "<a href='messages.php'>Messages <b>(".count($row).")</b></a>";
		}
		$sidebar = "You have {$GLOBALS['money']} {$GLOBALS['settings']['cost']}.<br />
		<a href='donate.php'>Donate money to friends</a><br />
		<ul>
		<li><a href='logout.php'>Log Out</a></li>";