我正在为我的博客开发后端,上传图像的代码按预期工作,但在数据库中没有写入任何内容。当我提交时,它会上传图像并将其移动到指定的文件夹,但在数据库中没有插入记录。这是用于上传的php。有没有办法解决这个问题?<form method="POST" action="functionabout.php" enctype="multipart/form-data"> <div class="col-md-9"> <!-- general form elements --> <div class="box box-primary"> <div class="box-header with-border"> <h3 class="box-title">Add About Content</h3> </div> <!-- /.box-body --> <div class="box-body"> <div class="form-group"> <label for="heading">Heading</label> <input placeholder="Write Heading" class="form-control" name="heading" type="text" id="heading" required> </div> <div class="form-group"> <label for="subheading">Sub Heading</label> <textarea class="form-control" placeholder="Write Sub Heading" name="subheading" cols="50" rows="10" id="subheading" required></textarea> </div> <div class="form-group"> <label for="message">Message</label> <textarea placeholder="Write Details" class="form-control" name="message" cols="50" rows="10" id="message" required></textarea> </div> <div class="form-group"> <label for="Filename">Signature</label> <input name="Filename" type="file"> </div></div> <div class="box-footer fboxm"> <button type="submit" class="btn btn-primary"><i class="fa fa-check icheck"></i>Submit</button> <button type="reset" class="btn btn-warning"><i class="fa fa-undo icheck"></i>Reset</button> </div> </div> </div> </div> <!-- /.box --> </div> <!-- right column --> </form>我希望同时上传文件并更新数据库。
1 回答
万千封印
TA贡献1891条经验 获得超3个赞
试试这个 :
$conn = mysqli_connect('localhost', 'root', '', 'db');
//Writes the information to the database
mysqli_query($conn,'INSERT INTO about (subheading,heading,message,signature)
VALUES ("'.$subheading.'","'.$heading.'","'.$message.'","'.$Filename.'")') ;
- 1 回答
- 0 关注
- 123 浏览
添加回答
举报
0/150
提交
取消