gpt4 book ai didi

php - mysql查询语法错误

转载 作者:太空宇宙 更新时间:2023-11-03 10:57:18 25 4
gpt4 key购买 nike

"INSERT INTO forum_topics (category_id, poster_id, poster_username, topic_title, topic_content, date) VALUES (".$category_id.", '$poster_id', '$topic_title', '$message', NOW()"; 

mysql_error() 表示语法有问题,但也可能是其他原因。我将发布变量只是为了让您知道它们来自哪里。

$message = $_POST['topic_message'];
$topic_title = $_POST['topic_title'];
$category_id = $_GET['id'];

编辑改成了

$topic_sql = "INSERT INTO forum_topics (category_id, poster_id, poster_username, topic_title, topic_content, date) VALUES (".$category_id.", '$poster_id', '$username', '$topic_title', '$message', NOW())";

但是还是不行...

最佳答案

您缺少 VALUES 的右括号:

... NOW())";

还有其他问题:

  • 参数计数不正确
  • 您的查询容易受到注入(inject)攻击,因为您没有使用 PDO/mysqli 的参数化查询

关于php - mysql查询语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19254524/

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