【发布时间】:2020-09-03 21:54:08
【问题描述】:
WPDB 插入错误
我需要帮助。我是 wordpress/php 编码的新手。我在主题文件夹中存储的 php 模板文件中编写了一个 wpdb 插入。 代码的目的是将表单数据插入到自定义表中......见下文。 编写代码:
if (isset($_POST["submit"])) {
// global $wpdb;
$cit1 = $_POST['cit1'];
$cit2 = $_POST['cit2'];
$cit3 = $_POST['cit3'];
$cit_text = $_POST['cit_text'];
$success = $wpdb -> insert(
wp_citations,
array(
'cit_id' => null,
'cit1' => $cit1,
'cit2' => $cit2,
'cit3' => $cit3,
'cit_text' => $cit_text,
'timestamp' => null
),
array(
'%s',
'%s',
'%s',
'%s'
)
);
}
但是,我使用了参考法典中的打印错误 <?php $wpdb->print_error(); ?> 函数,并将其作为错误返回:
"SELECT * FROM wp_posts WHERE (post_type = 'page' AND post_status = 'publish') ORDER BY menu_order,wp_posts.post_title ASC"
我正在编写的脚本不包含任何 wp 生成的表,仅包含我创建的自定义表。 我只能假设这是一个钩子或 wp 编码连接。
有人见过这个吗?如何绕过 wp 内部编码来使用新 php 文件中显式调用的内容?
不确定要尝试什么。
【问题讨论】:
标签: php html mysql wordpress insert