逃脱后的正确语法?

时间:2012-05-01 21:00:21

标签: php sql syntax

在转义后写入的正确语法是什么?

("SELECT torrent_download
FROM " . DB_PREFIX . "auctions WHERE
                auction_id='" . $item_details['auction_id'] . ); 

我得到的错误是意外的')'

我尝试了各种各样的“和”但似乎没有工作

3 个答案:

答案 0 :(得分:6)

在最终的'之前,您似乎错过了$item_details['auction_id']的结束),这将以双引号括起来"'");

("SELECT torrent_download
  FROM " . DB_PREFIX . "auctions WHERE
            auction_id='" . $item_details['auction_id'] . "'");

为了在双引号字符串中省去一点麻烦,我建议使用{}附件而不是连接所有引号。但是,您不能将常量DB_PREFIX括起来。

("SELECT torrent_download
  FROM " . DB_PREFIX . "auctions WHERE
        auction_id='{$item_details['auction_id']}'");

答案 1 :(得分:1)

("SELECT torrent_download
 FROM " . DB_PREFIX . "auctions WHERE
            auction_id='" . $item_details['auction_id'] . "'");
你试过那个吗?它是“跟着'然后再”。

答案 2 :(得分:0)

("SELECT torrent_download
FROM " . DB_PREFIX . "auctions WHERE
            auction_id='" . $item_details['auction_id'] ."'" );