title: Update database field on Facebook "Like"
body: <p>I'd like to track when people click the Facebook "Like" button on my website.</p>
  
  <p>I have a small script set-up, but it doesn't seem to work and I'm out of ideas of what it could be. Any suggestions? The AppID is correct and this script is just for testing so don't mind the lack of validation:</p>
  
  <p>index.html</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"&gt;
    &lt;head&gt;
      &lt;title&gt;FB Like Test&lt;/title&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div id="fb-root"&gt;&lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
  
  $(document).ready(function() {  
  
  window.fbAsyncInit = function() {
      FB.init({appId: 'x', status: true, cookie: true, xfbml: true});
      FB.Event.subscribe('edge.create', function(href, widget) {
          $.ajax({
              type: 'POST',
              url: 'like-sql.php',
              data: ({liked : 1})
          });
      });
  
      FB.Event.subscribe('edge.remove', function(response) {
          $.ajax({
              type: 'POST',
              url: 'like-sql.php',
              data: ({liked : 0})
          });
      });
  
  };
  (function() {
       var e = document.createElement('script');
       e.type = 'text/javascript';
       e.src = 'http://connect.facebook.net/nl_NL/all.js#appId=x&amp;amp;xfbml=1';
       e.async = true;
       document.getElementById('fb-root').appendChild(e);
  }());
  });  
  &lt;/script&gt;
  
   &lt;fb:like href="http://x.x.x" layout="button_count" show_faces="true"  width="500"&gt;&lt;/fb:like&gt;
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>like-sql.php</p>
  
  <pre><code>&lt;?php    
  $status = $_POST['liked'];    
  mysql_query("UPDATE `fb_like` SET umk_like = $status WHERE user_id = '3432'");    
  ?&gt;
  </code></pre>
  
  <p>I'm new to this whole jQuery ajax thingy, so I don't really know how I should debug this. Any suggestions are welcome :)</p>
  
  <p><strong>EDIT</strong>: Nevermind guys I got it.</p>
  
  <p>I'm testing this in an external file, where I don't have jQuery included by default ;) I can't believe it took me this long to figure it out, lol. Thanks anyway for all the help! </p>