我对PHP不太好,所以我遇到了一些应该更新wp_posts表的代码。问题是,当我尝试保存它时,WP会停用插件,说下面的代码中存在语法错误:
global $wpdb;
$dbresult = $wpdb->update($wpdb->post, ['post_title' => 'Test Title', 'post_content' => 'Test Content', 'group_access' => $group_access, 'tag_list' => $tag_list], ['ID' => 12095])) :
if (false === $dbresult) {
echo 'An error occurred wile updating...');$errors = $post_id->get_error_messages();
}
我相信如果我能弄清楚语法错误是什么的话会有用。
答案 0 :(得分:1)
有多个错误。现在应该修复。
global $wpdb;
$dbresult = $wpdb->update($wpdb->post, ['post_title' => 'Test Title', 'post_content' => 'Test Content', 'group_access' => $group_access, 'tag_list' => $tag_list], ['ID' => 12095]); // <- One ) to much, : but needed ;
if (false === $dbresult) {
echo ('An error occurred while updating...'); // <- Missing (
$errors = $post_id->get_error_messages();
}