Facebook Callback

Discussion in 'PHP' started by Likebot, Apr 11, 2012.

  1. #1
    Hey guys i have a big problem with my site that when other click on a Like Button it will not remove from the site, still stays here. can anyone please help me..

    here are the codes.

    facebook.php

    <?
      $site2 = mysql_query("SELECT * FROM `facebook` WHERE (`active` = '0' AND `points` > '4') AND `id` NOT IN (SELECT `site_id` FROM `liked` WHERE `user_id`='{$data->id}') ORDER BY `cpc` DESC LIMIT 0, 15");
      $ext = mysql_num_rows($site2);
    if($ext > 0){
    ?><div id="fb-root"></div>
    <script>
    window.fbAsyncInit = function() {
     FB.init({status: true, cookie: true, xfbml: true});
     var user= "<? echo $data->id;?>";
     document.getElementById("Hint").style.display='block';
     FB.Event.subscribe('edge.create', function(response) {
        $.ajax({
            type: "POST",
            url: "fbreceive.php",
            data: "data="+response + "---" + user,        
            cache: false
        });
        $("#Hint").html('<font size="3"><b>Punkty dodane prawidłowo!</b></font>');
        removeElement('tbl', response);
     });
    };
    (function() {
     var e = document.createElement('script');
     e.type = 'text/javascript';
     e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
     e.async = true;
     document.getElementById('fb-root').appendChild(e);
     }());
    
    function removeElement(parentDiv, childDiv){
         if (document.getElementById(childDiv)) {     
              var child = document.getElementById(childDiv);
              var parent = document.getElementById(parentDiv);
              parent.removeChild(child);
         }
    }
      function refreshpage()
       {
          window.location.reload();
       }
    </script>
    <center><div id="Hint" style="display:none;"></div></center>
    <div id="tbl">
    <?
      for($j=1; $site = mysql_fetch_object($site2); $j++)
    {
    ?>    
    PHP:
    fbreceive.php

    <?include('config.php');if(isset($_POST['data'])){$x = explode('---', $_POST['data']);$site = mysql_fetch_object(mysql_query("SELECT * FROM `facebook` WHERE `facebook`='{$x[0]}'"));mysql_query("UPDATE `users` SET `coins`=`coins`+'{$site->cpc}' WHERE `id`='{$x[1]}'");mysql_query("UPDATE `facebook` SET `likes`=`likes`+'1', `points`=`points`-'{$site->cpc}' WHERE `facebook`='{$x[0]}'");mysql_query("INSERT INTO `liked` (user_id, site_id) VALUES('{$x[1]}','{$site->id}')");}?>
    PHP:
    I really need help
     
    Likebot, Apr 11, 2012 IP