我正在尝试在wordpress插件的自定义表中更新和删除。我为公司详细信息和影响者详细信息添加了两个自定义表,“ wp_company_wp”,“ wp_influencer”数据已成功插入,但更新和删除时间均显示500个内部服务器错误。
jQuery('#editCompanyForm').validate({
submitHandler:function(){
var post_data1 = $("#editCompanyForm").serialize()+"&action=edit_company_form";
jQuery.post(ajax_url_obj,post_data1,
function(resp){
var data = JSON.parse(resp);
console.log(data);
location.reload();
if (data.status==1) {
jQuery.notifyBar({
cssClass:"success",
html:data.message
})
}
}
)
}
});
// delete
jQuery(document).on("click",".delinfluencer",function(){
var com_id = jQuery(this).attr('delinfluencer');
// console.log(com_id);
var post_data = "action=influencer_form¶m=delete_influence&influence_id="+com_id;
jQuery.post(ajax_url_obj,post_data,
function(res){
console.log(res);
var data = JSON.parse(res);
console.log(data);
location.reload();
}
)
})
});
// php page code
//delete
elseif($_REQUEST['param']=="delete_influence"){
// print_r($_REQUEST);
$wpdb->query(
$wpdb->prepare(
"DELETE from wp_influencer where id = %d",3
)
);
echo json_encode('Database insertion successful');
}
wp_die('failed');
// edit code
add_action('wp_ajax_edit_company_form','prefix_ajax_edit_company_form');
function prefix_ajax_edit_company_form(){
if(isset($_POST['edit_company'])){
$wpdb->update(
'wp_company_wp',
array(
"name"=>$_REQUEST['name'],
"email"=>$_REQUEST['email'],
"company_name"=>$_REQUEST['company_name'],
"image"=>$_REQUEST['image_url']
),array("id"=>10));
echo json_encode(array("status"=>1,"message"=>'Database
update successful')); exit();
// print_r($_REQUEST);
}
}
显示500个内部服务器错误