How to replace text with appropriate variable
Posted: Sat Oct 16, 2010 4:10 pm
I am working on my site and adding the ability for users to like different pages and I would like to be able to keep track of the number of likes each website url has and insert them into my database. So far it works fine for if I want to submit one url to check but I would like to set it up as a cron job to check multiple url's using a function. The problem that has me stumped is how do I take the "http://www.test.com" out of 'query' => 'select total_count from link_stat where url = "http://www.test.com";' and replace it with a variable. Every method I have tried has failed and i'm not sure if it has something to do with facebooks php sdk or not. Any help would be very much appreciated. Chance
Code: Select all
<?php
require './facebook.php';
include 'config.php';
$facebook = new Facebook(array(
'appId' => 'my app id',
'secret' => 'my app secret',
'cookie' => true,
));
$website = "http://www.test.com";
$result = $facebook->api(array(
'method' => 'fql.query',
'query' => 'select total_count from link_stat where url = "http://www.test.com";'
));
$fblikes = $result[0]['total_count'];
mysql_query("UPDATE likes SET count = '$fblikes' WHERE website = '$website'");
?>