【发布时间】:2013-03-13 19:37:17
【问题描述】:
这是我页面顶部的 php 代码:
if(!$_SESSION['username']){
header("Location: ../error.php?id=1");
}
$teamgamertag = $_POST["gamertag"];
$teamgame = $_POST["game"];
$teamtype = $_POST["type"];
$teamname = $_POST["name"];
$teamconsole = $_POST["console"];
if(isset($_POST["submit"])){
$sql2 = mysql_query("INSERT INTO teams (name, game, players, creator, console, leaders, type, score) VALUES ('$teamname', '$teamgame', '$teamgamertag', '$teamgamertag', '$teamconsole', '$teamgamertag', '$teamtype', '0'") or die(mysql_error());
if($sql2){
header("../results.php?id=1");
}else{
exit();
}
}
?>
我不知道问题是什么以及在哪里解决它。提前感谢您的帮助。
【问题讨论】:
-
这里没有明显的语法错误,除了缺少开头的
<?php标签。很可能是您在undefined index: gamertag或类似问题中的问题,因为您在尝试使用它们之前没有检查以确保它们已设置。 -
@NicholasPickering 它在 SQL 中缺少
) -
您的第二个标题格式不正确
-
这个,是“不是一个真正的问题”的完美例子。
-
另外,来自手册
header()HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path,- 即。header("Location: http://$host.$uri");