Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql SQL查询中出现意外的T_常量\u封装的\u字符串错误_Mysql_Wordpress_Encapsulation - Fatal编程技术网

Mysql SQL查询中出现意外的T_常量\u封装的\u字符串错误

Mysql SQL查询中出现意外的T_常量\u封装的\u字符串错误,mysql,wordpress,encapsulation,Mysql,Wordpress,Encapsulation,我在以下SQL查询中遇到意外的T_常量_封装_字符串错误: mysql_query (UPDATE 'wp_posts' SET 'post_status' = 'publish' WHERE 'post_id' = '$id'); 你们能看到错误在哪里吗 以下是完整的代码,以防有所帮助: $key = 'feed'; $post_ids = array(2263, 2249); foreach ($post_ids as $id) { $feedurl =

我在以下SQL查询中遇到意外的T_常量_封装_字符串错误:

mysql_query (UPDATE 'wp_posts' SET 'post_status' = 'publish' WHERE 'post_id' = '$id');
你们能看到错误在哪里吗

以下是完整的代码,以防有所帮助:

    $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语句用引号括起来-


将SQL语句用引号括起来-

mysql\u query()
接受一个字符串。PHP正在寻找散布着字符串的常量,这不是有效的PHP语法

您需要对字符串进行分隔,
是常用的选择,但也有herdoc语法

.

mysql\u query()
接受字符串。PHP正在查找散布字符串的常量,这不是有效的PHP语法

您需要对字符串进行分隔,
是常用的选择,但也有herdoc语法


.

谢谢亚历克斯-我感谢你的帮助!谢谢亚历克斯-我感谢你的帮助!
mysql_query ("UPDATE 'wp_posts' SET 'post_status' = 'publish' WHERE 'post_id' = '$id'");