本文介绍了SQL查询中出现意外的T_CONSTANT_ENCAPSED_STRING错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在以下SQL查询中我收到意外的T_CONSTANT_ENCAPSED_STRING错误:
I am getting an unexpected T_CONSTANT_ENCAPSED_STRING error in the following SQL query:
mysql_query (UPDATE 'wp_posts' SET 'post_status' = 'publish' WHERE 'post_id' = '$id');
你们能看到错误可能在哪里吗?
Can you guys see where the error might be?
这里是完整的代码,以防万一:
Here is the full code in case it helps:
$key = 'feed';
$post_ids = array(2263, 2249);
foreach ($post_ids as $id) {
$feedurl = get_post_custom_values($key, $id);
$feedurlstr = implode($feedurl);
// Ignore - it determines whether feed is live and returns $result
LiveOrNot($feedurlstr);
if ( $result == "live" ) {
mysql_query (UPDATE 'wp_posts' SET 'post_status' = 'publish' WHERE 'post_id' = '$id');
}
elseif ( $result == "notlive" ) {
mysql_query (UPDATE 'wp_posts' SET 'post_status' = 'draft' WHERE 'post_id' = '$id');
}
endif;
}
推荐答案
将SQL语句用引号引起来-marks-
。
Wrap your SQL statements in quote-marks - "
.
mysql_query ("UPDATE 'wp_posts' SET 'post_status' = 'publish' WHERE 'post_id' = '$id'");
这篇关于SQL查询中出现意外的T_CONSTANT_ENCAPSED_STRING错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!