So, I am trying to do a simple query which works fine when I put in the URL manually as a string. But when I put it as a variable it doesn’t work. I even checked the variable and the variable has the URl in it. Never put a variable in a WHERE statement so not sure if it is an echo thing or what, just that nothing seems to work.
$external_result = $facebook->api(
array(
'method' => 'fql.query',
'query' => 'SELECT share_count,
like_count,
comment_count,
total_count
FROM link_stat
WHERE url="{$urlf}";'
)
);
echo $external_result[0]['total_count'];
There’s a difference between single and double quoted strings in PHP syntax. A single quoted string does not offer variable interpolation. Whereas double quoted strings do allow you to interpolate variables inside string literals. See the manual on PHP strings for more details.
Here’s what you need to do.
By replacing your single quotes around that string to double quotes you now get PHP to replace
$urlfwith it’s actual value.