我正在将数据插入 WordPress 的数据库中。我在网络选项卡中收到错误:
致命错误:未捕获的错误:在 null 上调用成员函数 insert()
这是我的逻辑
<?php
global $wpdb; // <--- making $wpdb as global
$wpdb->insert('contact',
array(
'name' => $_POST['c_name'],
'email' => $_POST['c_email'],
'phone' => $_POST['c_mobileno'],
'type_of_services' => $_POST['c_type_of_services'],
'message' => $_POST['c_message']
),
array(
'%s',
'%s',
'%s',
'%s',
'%s',
)
);
// $wpdb->show_errors();
?>
jQuery(document).ready(function($) {
$('#contact_form').on('submit', function(e) {
e.preventDefault();
var form = $(this);
$.ajax({
url: "/process.php",
type: "post",
data: form.serialize(),
dataType: "JSON",
success: function(response) {
alert("submited");
}
});
});
});
鸿蒙传说