PHP SQL query error

前端 未结 6 2033
忘了有多久
忘了有多久 2021-01-26 07:26

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         


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-26 08:06

    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.

提交回复
热议问题