所以,我将在下面发布代码。代码下面是我提出问题的地方。
if (!empty($_SESSION['username']) && !empty($_SESSION['password']))
{
$server=mysql_real_escape_string($_POST['server']);
$teamname=mysql_real_escape_string($_POST['teamname']);
$creator=$_SESSION['username'];
$verify = mysql_real_escape_string($_POST['verify']);
$date = date("F j, Y, g:i a");
if (!empty($teamname)) {
// if ($verify == "wookie" ||
// $verify == "Wookie" ||
// $verify == "WOOKIE")
// {
$sql="INSERT INTO rated_teams (server, name, creator, created, players, win, loss)
VALUES ('$server', '$teamname', '$creator','$date', '', '', '')";
if (mysql_query($sql,$con))
{
echo "<p>Added ". $teamname . " on " . $server . " by " . $creator . " on " . $date ." <br /><a href='myprofile.php'>Return to Profile</a></p>";
}
else
{
echo $sql . "<br />";
echo "<br /><h1>Error</h1>";
echo "<p><a href='myprofile.php'>Sorry, your team registration has failed. Please go back and try again.</a></p>
<br />" . $teamname . " on " . $server . " by " . $creator . " on " . $date;
}
//} else { echo "That isn't how you spell Wookie!"; }
} else { echo "Team Name is empty, <a href='myprofile.php'>go back and give yourself a Team Name</a>"; }
} else { echo "You must be <a href='login.php'>logged in</a>!"; }
这个问题是“if (mysql_query($sql,$con))”这一行直接进入 ELSE。我假设问题出在我的 $sql 上,但我无法确定它在哪里。另一双眼睛真的很有帮助。非常感谢!