亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

致命錯誤:未捕獲的錯誤:在 wordpress 中調用 null 上的成員函數 insert()

致命錯誤:未捕獲的錯誤:在 wordpress 中調用 null 上的成員函數 insert()

PHP
牛魔王的故事 2022-05-27 10:06:34
我正在將數據插入 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");      }    });  });     });
查看完整描述

1 回答

?
鴻蒙傳說

TA貢獻1865條經驗 獲得超7個贊

希望能幫到你。在你的 php 文件中添加:


define( 'BLOCK_LOAD', true );

require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php' );

require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-includes/wp-db.php' );

$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);


查看完整回答
反對 回復 2022-05-27
  • 1 回答
  • 0 關注
  • 108 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號