-2

所以我正在做一个简单的 PHP/SQL/HTML 调查,由于某种原因它没有提交到数据库......没有错误或语法错误,页面显示正常,只是没有提交并将其插入 phpmyadmin 的“调查表

数据库和表名是正确的,我通过使用 phpmyadmin 中的“插入”按钮插入行来仔细检查 SQL,它工作正常,给了我相同的 SQL,所以我认为它必须与我的 PHP

谢谢,这是我的代码

<?php
include "Header.php";

if (!$User)
{
header("Location: index.php"); exit();
}

echo"
<center><br /><br /><br /><h1>Social-Limiteds Survey</h1><br /><h3>Please take a moment         to fill out this survey to help us improve the site</h3><br /><br />
In your opinion, who is the most helpful staff member?</font><br /><br /><form     action='' method='post'><textarea name='Quest1' rows='2' cols='20'></textarea><br />
In your opinion, who is the best item creator who is currently NOT a staff member?    </font><br /><br /><form action='' method='post'><textarea name='Quest2' rows='2'     cols='20'></textarea><br />
In your opinion, who is the best Forumer?</font><br /><br /><form action=''     method='post'><textarea name='Quest3' rows='2' cols='20'></textarea><br />
In your opinion, who is the best Artist?</font><br /><br /><form action=''     method='post'><textarea name='Quest4' rows='2' cols='20'></textarea><br />
Is Braixen cute? (Yes/No) </font><br /><br /><form action='' method='post'><textarea     name='Quest5' rows='2' cols='20'></textarea><br />
<input type='submit' name='submit' value='Send'></form></center>";


$Ques1 = mysql_real_escape_string(strip_tags($_POST['Quest1']));
$Ques2 = mysql_real_escape_string(strip_tags($_POST['Quest2']));
$Ques3 = mysql_real_escape_string(strip_tags($_POST['Quest3']));
$Ques4 = mysql_real_escape_string(strip_tags($_POST['Quest4']));
$Ques5 = mysql_real_escape_string(strip_tags($_POST['Quest5']));

if ($Submit) {

mysql_query("INSERT INTO `socialli_main`.`Survey` (`Question1`, `Question2`,     `Question3`, `Question4`, `Question5`, `Username`, `ID`) VALUES ('$Ques1', '$Ques2',     '$Ques3', '$Ques4', '$Ques5', '$myU->Username', NULL);");

header("Location: index.php"); exit();
}

include "Footer.php";
4

1 回答 1

1

尝试将每个参数更改为这样的结构:"'.$Ques1.'"

其次,你确定$Submit == true吗?

您可能希望启用错误调试,以便查看所有警告和错误,这可能会向您显示解决方案:

ini_set('display_errors', 'On');
error_reporting(E_ALL);

希望这可以帮助!

于 2013-10-21T22:19:09.630 回答