我在使用这个 MySql 查询时遇到问题:
INSERT INTO groups (NAME, DESC, TIME, OWNER) VALUES ('$GNAME', '$DESC', '$TIME', '$UID')
本质上,该脚本将组名、说明、时间和注册组的人的用户名添加到 mysql 数据库中。
完整脚本:
<?php
include_once('include/session.php');
$GNAME = $_POST['groupname'];
$DESC = $_POST['desc'];
$SPAM = $_POST['spam'];
$UID = $_POST['UID'];
$TIME = date('Y-m-d H:i:s');
if($SPAM == "queuee"){
$query ="INSERT INTO groups (NAME, DESC, TIME, OWNER) VALUES ('$GNAME','$DESC','$TIME', '$UID')";
$result = mysql_query($query) or die("There as been an Error! <hr>Error:<hr>".mysql_error() ."<br><hr><a href=\"../index.php\">Go Back</a>");
header("Location: ../group.php?id=$GNAME");
}else{
?>
The Security Question was wrong. Try Again.
<?
}
?>
我使用 Phpmyadmin 将查询直接运行到 MySql 本身。但是它仍然抛出了一个错误。错误是:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC, TIME, OWNER) VALUES ('$GNAME', '$DESC', '$TIME', '$UID')' at line 1
非常感谢任何帮助,也许我完全是个傻瓜,没有注意到明显的错误。如果您需要更多信息,请询问!
非常感谢。