gpt4 book ai didi

php - 向php数据库发送数据

转载 作者:搜寻专家 更新时间:2023-10-30 20:16:59 25 4
gpt4 key购买 nike

所以,我有以下 php 来向数据库提交数据(名称):

<?php   
if(!empty($_POST)){
global $wpdb;
$table = 'names';
$current_user = wp_get_current_user();
$post_id = 123;
$parent_id = 0;
date_default_timezone_set('Canada/Mountain');
$date = date('m/d/Y h:i:s a', time());
$data = array(
'post_id' => $post_id,
'parent_id' => $parent_comment_id,
'author_id' => $current_user,
'date' => $date,
'name_content' => $_POST['name']

);
$wpdb->insert($table, $data);
} else {
?>
<form method="post">
<input type="text" id="name" name="name" value=""/>
<input type="submit">
</form>
<?php } ?>

但是,它没有发送任何数据,我不确定错误在哪里。

我缺少什么功能?

谢谢!

最佳答案

可能您错过了与数据库的连接。有点像

$dbh=mysql_connect(DB_HOST,DB_USER,DB_PAS) or die("Connection error");

关于php - 向php数据库发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34364708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com