php - mysqli_query 不工作 INSERT INTO 不工作
问题描述
好的,所以这是非常基本的,但它让我发疯
<div class="heading"><h2>Make a post<h2></div>
<form action="post.php" method="POST">
<div class="head"><h3>Title</h3></div>
<textarea name="title" rows="2" cols="45"></textarea>
<div class="desc"><h3>Content</h3></div>
<textarea name="description" rows="15" cols="45"></textarea><br>
<input type="submit" value="Submit">
<p id="error_p"><?php echo (!empty($_SESSION['post_message']))? $_SESSION['post_message']:""; ?></p>
</form>
html部分
if(!empty($_POST['title']) && !empty($_POST['description']))
{
$title=$_POST['title'];
$description=$_POST['description'];
$user_id=$_COOKIE['user_id'];
$query="INSERT INTO posts (title,description,user_id)
VALUES('".$title."','".$description."','".$user_id."');";
$result=mysqli_query($conn,$query);
if($result)
{
$_SESSION['post_message']="Posting succ";
header('Location: profile.php');
}
else
{
$_SESSION['post_message']="something gone wrong";
header('Location: profile.php');
}
}
php部分
我只是找不到问题,无论我做什么,我都会遇到“出现问题”错误。
解决方案
推荐阅读
- xamarin - 如何在 XAMARIN android 应用程序中向 HockeyApp SDK 发送已处理的异常?
- firebase - 如何正确跟踪游戏战斗结果游戏分析事件
- java - 为 HANA JDBC 创建一个连接字符串?
- ballerina - 如何确保我的类型和函数文档出现在 Ballerina Central 中?
- socket.io - 是否可以将 Socket.io 与 NuxtJs 一起使用?
- java - 如何防止“Firestore,提供的文档路径不能为空”错误?
- docker - 更改现有 docker commit 的作者身份和消息
- java - iText 显示 unicode 字符的问题
- java - Memcached 错误:管道损坏/对等方重置连接
- odoo - xml 记录 Ir.rule AssertionError: Element odoo has extra content: 记录