I have some problem with type conversation in this code (working with Facebook PHP SDK 3.0.1):
$page_id = 192485754113829;
$post_limit = 2;
$query = \"select po
It has nothing to do with type-conversion, it's just your quotes that are wrong. The code should look like this:
$page_id = 192485754113829;
$post_limit = 2;
$query = "select post_id, source_id, actor_id, target_id, created_time, likes, message, attachment, comments from stream where source_id = ".$page_id." LIMIT ".$post_limit."";
You think you do string concatenation, but you don't. The dots are inside the double quoted string and hence have no special meaning. They are not valid in a SQL statement.
As variables are parsed in double quoted strings you can do:
"select (...) where source_id = $page_id LIMIT $post_limit";
If you want to use string concatenation, you have the terminate the string properly:
'select (...) where source_id = ' . $page_id . ' LIMIT ' . $post_limit;
Read more about strings.
$query = "select post_id, source_id, actor_id, target_id, created_time, likes, message, attachment, comments from stream where source_id = '$page_id' LIMIT $post_limit";
or
$query = "select post_id, source_id, actor_id, target_id, created_time, likes, message, attachment, comments from stream where source_id = '".$page_id."' LIMIT ".$post_limit."";
(if page_id
is an integer you can write it without any quotes)
the problem is in quotes.
This is a syntax error. It won't work on any host.
You are basically generating this query (I've reformatted it for better display):
select post_id, source_id, actor_id, target_id, created_time, likes,
message, attachment, comments
from stream
where source_id = '.1.9248575411383E+14.' LIMIT '.2.'
This is by no means valid SQL. To begin with, you have to get rid of the additional dots.
Apart from your invalid SQL, 192485754113829
is very large integer. The maximum size of integers depends on the platform but in my computer the limit is 2^32 which is smaller than your number. That means that PHP will handle it as a floating point number and you will lose precision. Given that it's an ID, I suggest you use PHP strings instead.
$query = "select post_id, source_id, actor_id, target_id,
created_time, likes, message, attachment, comments
from stream where source_id = '$page_id' LIMIT $post_limit ";
would work.
Or if you want to use concatenation :
$query = "select post_id, source_id, actor_id, target_id,
created_time, likes, message, attachment, comments
from stream where source_id = ".$page_id." LIMIT ".$post_limit;