我得到的错误信息是:
致命错误:未捕获PDOException:SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法出错;查看与您的MariaDB服务器版本相对应的手册,以获得正确的语法,以便在“玩家姓名”,“玩家年龄”,“玩家团队”等附近使用?#39;玩家年龄'玩家团队' )价值观('威廉',' 27','切尔西')'在C:\ xampp \ htdocs \ WebProgrammingWebsite \ add-player.php的第1行:9堆栈跟踪:#0 C:\ xampp \ htdocs \ WebProgrammingWebsite \ add-player.php(9):PDO->准备(& #39; INSERT INTO pla ...')在第9行的C:\ xampp \ htdocs \ WebProgrammingWebsite \ add-player.php中抛出#1 {main}
我已经仔细检查并试图改变第9行所写的内容,但是我无法让它发挥作用。我也尝试过使用整个" Bind_param"事情,但我只是一个菜鸟,没有任何工作。它本身就是一些愚蠢的语法错误,但它让我发疯 这是我的代码:
<?php
require("connect.php");
if(isset($_POST['submit'])) {
$name = $_POST['p_name'];
$age = $_POST['p_age'];
$team = $_POST['p_team'];
$stmt = $con->prepare("INSERT INTO player ('Player Name', 'Player Age', 'Player Team') VALUES ('".$name."', '".$age."', '".$team."')");
$stmt->execute();
$stmt->closeCursor();
header("Location: display-players.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Football Database</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700" rel="stylesheet">
</head>
<body>
<div class="wrapper">
<form class="add" action="" method="post">
<label>Player Name</label>
<input type="text" name="p_name"><br>
<label>Player Age</label>
<input type="text" name="p_age"><br>
<label>Player Team</label>
<input type="text" name="p_team"><br>
<input id="submit" name="submit" type="submit" value="Submit">
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="resources/js/main.js"></script>
</body>
</html>