get yourself an editor that is PHP aware, that will help identfying tags, code blocks
there's lots of them out there ranging from the PHP 'envrionments/IDEs' like Eclipse, Netbeans to Editors such as HTML kit
looking at line 205
PHP Code:
$sql = "SELECT * FROM Friends WHERE UserID = "$. _SESSION['UserID']." AND
FriendID = $row->UserID AND accepted = 0 AND invited = 1";
the problem is the
Code:
UserID = "$. _SESSION['UserID']
which should read
Code:
UserID = ".$_SESSION['UserID']
however assuming that userid is a string / text / char column then the literal value should be quoted
PHP Code:
$sql = "SELECT * FROM Friends WHERE UserID = '".$ _SESSION['UserID']."' AND.......
you may also need to refer to the row array item outside quotes
PHP Code:
$sql = "SELECT * FROM Friends WHERE UserID = '".$_SESSION['UserID']."' AND
FriendID = '".$row->UserID."' AND accepted = 0 AND invited = 1";