这个简单的PHP / SQL调查有什么问题?

时间:2013-10-21 22:11:46

标签: php mysql

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

数据库和表名是正确的,我通过在phpmyadmin中使用'Insert'按钮插入行来仔细检查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";

1 个答案:

答案 0 :(得分:1)

尝试将每个参数更改为结构如下:"'.$Ques1.'"

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

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

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

希望这有帮助!