元标记中的PHP不起作用?

I'm very new to programming so bear with me... My site is based on Wordpress, so I have an index page that says <?php get_header(); ?> and <?php include('pagecontent.php'); ?>... My header.php contains what you'd expect and pagecontent.php is actually a pretty complex page that grabs several variables from a database (for instance, $result->properties->name). I'm starting to integrate Facebook Connect plugins (the like button and comment box), and when I put PHP in my <meta> tags in the <head>, Facebook doesn't recognize the value of $result->properties->name... IF my php files were all the same, the relevant code would look like this:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
[REMOVED THE DIV TAG HERE]<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<?php
echo '<meta property="og:title" content="' . $result->properties->name . ' on Name of Site"/>';
echo '<meta property="og:type" content="movie"/>';
echo '<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>';
echo '<meta property="og:site_name" content="Name of Site"/>';
echo '<meta property="fb:admins" content="698461078"/>';
echo '<meta property="og:description" content="' . $result->properties->description . '"/>';
?>
</head>
<body>
[MOVED DIV TAG DOWN HERE]<div id="fb-root"></div><fb:like href="http://www.sitename.net/?sg=' . $sg_id . '&task=0" send="false" layout="button_count" width="450" show_faces="true" action="recommend" font="tahoma"></fb:like>
</body>

I tried to be as complete as possible to avoid guesswork :P This code gives liked pages the title " on Name of Site" instead of "Name of Movie on Name of Site". Why isn't it able to grab the variable? Is there something I can do to modify the meta tags from within pagecontent.php? Please don't be afraid to state the obvious things! Many thanks ;)

On your comments above you say:

$result is being populated by an S3 database - the code that grabs the value is about 20 lines before the tag. So it's effectively after the meta tags and before the like button

Move the code that grabs the value before the meta tags.