在 fql 查询中使用变量

发布于 2024-12-27 22:16:31 字数 580 浏览 0 评论 0原文

这里有一些语法问题。尝试使用如下变量在任何页面上获取相似计数:

$url = "http://www.my-domain.com"
$result = $facebook->api(array(
    'method' => 'fql.query',
    'query' => 'SELECT  total_count from link_stat  where  url ="$url";
));
$fb_fans = $result[0]['total_count'];

但是,当我将 $url 替换为实际值时,它会起作用:

$result = $facebook->api(array(
    'method' => 'fql.query',
    'query' => 'SELECT  total_count from link_stat  where  
    url ="http://www.my-domain.com";
));
$fb_fans = $result[0]['total_count'];

有人能告诉我我在这里明显忽略了什么吗?

Having some problems with syntax here. Trying to get like counts on any page using a variable like so:

$url = "http://www.my-domain.com"
$result = $facebook->api(array(
    'method' => 'fql.query',
    'query' => 'SELECT  total_count from link_stat  where  url ="$url";
));
$fb_fans = $result[0]['total_count'];

However it works when I replace $url with the actual value as such:

$result = $facebook->api(array(
    'method' => 'fql.query',
    'query' => 'SELECT  total_count from link_stat  where  
    url ="http://www.my-domain.com";
));
$fb_fans = $result[0]['total_count'];

Can someone tell me what I am obviously over looking here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一片旧的回忆 2025-01-03 22:16:31

$url = "http://www.my-domain.com"
$result = $facebook->api(array(
    "method" => "fql.query",
    "query" => "SELECT  total_count from link_stat  where  url ='".$url."'"
));
$fb_fans = $result[0]['total_count'];


$url = "http://www.my-domain.com"
$result = $facebook->api(array(
    "method" => "fql.query",
    "query" => "SELECT  total_count from link_stat  where  url ='".$url."'"
));
$fb_fans = $result[0]['total_count'];

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文