php:变量值未保存在db中

php:变量值未保存在db中,php,Php,我有一个php代码,其中我使用登录的用户名。然后表单来了,然后我需要将登录的用户名保存在db中 <?PHP function renderForm($id, $task, $comments, $assignee, $priority, $status, $dataum1, $dataum2, $error ) { require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin())

我有一个php代码,其中我使用登录的用户名。然后表单来了,然后我需要将登录的用户名保存在db中

<?PHP
 function renderForm($id, $task, $comments, $assignee, $priority, $status, $dataum1, $dataum2, $error )
 {
require_once("./include/membersite_config.php");

if(!$fgmembersite->CheckLogin())
{
    $fgmembersite->RedirectToURL("login.php");
    exit;
}
$user = $fgmembersite->UserFullName();
?>

这里有Html表单

<?php
 }



 // connect to the database
 include('configdb1.php');

 // check if the form has been submitted. If it has, process the form and save it to the database
 if (isset($_POST['submit']))
 { 

 mysql_query("INSERT INTO comments (comment_id, comments, user) VALUES ('$id', '$text', '$user')")
 or die(mysql_error()); 


?>


                         ;nbsp





尝试此操作(添加
),因为注释可能有特殊字符:

mysql_query("INSERT INTO comments (comment_id, comments, user) VALUES ('".$id."', '".$text."', '".$user."')") or die(mysql_error()); 
是否有名为“提交”的字段? 我的猜测是,检查表单是否已发布是不正确的。 这就是为什么查询从未执行

尝试以下方法:

if (count($_POST) > 0)
// QUERY

使用xDebug并告诉我们,您有哪些错误消息。此外,这组字母甚至无法执行,不要称之为“代码”。请先阅读书籍。是否插入了其他字段?如果您使用var_dump($user),输出是什么在查询之前,$user的变量类型是否与数据库中的变量类型兼容?我是否要在此处发布我的整个页面代码?它太长了。我可以吗?
if (count($_POST) > 0)
// QUERY