duanlu6114 2015-06-01 17:51
浏览 57

解析错误:语法错误,意外的“14”(T_CONSTANT_ENCAPSED_STRING)在......第11行[重复]

This question already has an answer here:

I have a code like this but it gives me error

 include_once 'wp-config.php';
    $number = 14 ;
    $result = mysql_query ("SELECT * FROM 'wp_posts' WHERE post_status='publish' ORDER BY ID DESC LIMIT $number 14 ); 
    while ($row = mysql_fetch_array($result)) 
  {
 $id = $row["ID"];
 $title = $row["post_title"];
 $content = $row["post_content"];

My blog is wp so any clue to slove this

Thank you

</div>
  • 写回答

1条回答 默认 最新

  • duangu4980 2015-06-01 17:54
    关注

    You're missing the end double quote in your MYSQL query. Should be :

        $result = mysql_query ("SELECT * FROM 'wp_posts' WHERE post_status='publish' ORDER BY ID DESC LIMIT $number 14 "); 
    

    However, this is still going to have another bug as LIMIT $number 14 is garbage.

    • Do you want to limit by 14 or $number?
    • is $number an offset? if so you'd want LIMIT $number, 14

    I'm guessing by the rest of your code you just want to limit by number and the addition of 14 to the queryis a mistake. So use:

    $result = mysql_query ("SELECT * FROM 'wp_posts' WHERE post_status='publish' ORDER BY ID DESC LIMIT $number "); 
    
    评论

报告相同问题?