可能是一些愚蠢的事情,因为我的 MySQL PHP 知识太生疏了.. 我清理了所有我能做的错误,但我仍然无法写入我的数据库。任何人都可以阐明可能出了什么问题,因为它甚至不再打印错误了。谢谢:
<?php
$conn=mysql_connect("127.0.0.1","root","","pe_results");
if (isset($_POST['Name'])) {
$Name = $_POST['Name'];
}
if (isset($_POST['Short'])) {
$Short = $_POST['Short'];
}
if (isset($_POST['Med'])) {
$Med = $_POST['Med'];
}
if (isset($_POST['Long'])) {
$Long = $_POST['Long'];
}
if (isset($_POST['VLong'])) {
$VLong = $_POST['VLong'];
}
if (isset($_POST['Extreme'])) {
$Extreme = $_POST['Extreme'];
}
if (isset($_POST['LJump'])) {
$LJump = $_POST['LJump'];
}
if (isset($_POST['HJump'])) {
$HJump = $_POST['HJump'];
}
if (isset($_POST['Shotputt'])) {
$Shotputt = $_POST['Shotputt'];
}
if (isset($_POST['Discuss'])) {
$Discuss = $_POST['Discuss'];
}
if (isset($_POST['Javelin'])) {
$Javelin = $_POST['Javelin'];
}
if (isset($_POST['Date'])) {
$Date = $_POST['Date'];
}
if (isset($_POST['Year'])) {
$Year = $_POST['Year'];
}
$sql="INSERT INTO results_main (Name, Short, Med, Long, VLong, Extreme, LJump, HJump, Shotputt, Discuss, Javelin, Date, Year)
VALUES ('$Name', '$Short', '$Med', '$Long', '$VLong', '$Extreme', '$LJump', '$HJump', '$Shotputt', '$Discuss', '$Javelin', '$Date', '$Year')";
$result = mysql_query($sql,$conn);
if($result){
echo"<br/>Everythings been saved";
echo "<BR>";
echo "<a href='index.html'>Back to the main page</a>";
}
else {
echo 'Fatal Error, you information has not been saved';
}
// close connection
mysql_close($conn);
?>
这是更新:
查询是: INSERT INTO results_main (Name, Short, Med, Long, VLong, Extreme, LJump, HJump, Shotputt, Discuss, Javelin, Date, Year) VALUES ('Chris Davern', '10:00', '20: 00'、'40:00'、'80:00'、'15:00'、'100m'、'10m'、'15m'、'50m'、'400m'、'2013-03-27'、' 9')
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“Long, VLong, Extreme, LJump, HJump, Shotputt, Discuss, Javelin, Date, Year) 附近使用正确的语法