Update query PHP MySQL(更新查询 PHP MySQL)
问题描述
谁能帮我理解为什么这个更新查询没有更新我数据库中的字段?我在我的 php 页面中有这个来从数据库中检索当前值:
Can anybody help me understand why this update query isn't updating the fields in my database? I have this in my php page to retrieve the current values from the database:
这是我的 HTML 表单:
Here i my HTML Form:
这是我的editblogscript":
and here is my 'editblogscript':
我不明白为什么它不起作用.
I don't understand why it doesn't work.
推荐答案
您必须在查询中的任何 VARCHAR 内容周围使用单引号.所以你的更新查询应该是:
You have to have single quotes around any VARCHAR content in your queries. So your update query should be:
此外,直接使用 POST 中的内容更新数据库也是一种错误的做法.您应该使用 mysql_real_escape_string 函数清理传入的数据.
Also, it is bad form to update your database directly with the content from a POST. You should sanitize your incoming data with the mysql_real_escape_string function.
这篇关于更新查询 PHP MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!