-1

我正在执行 MySQL 更新语句,当我单击提交时,会发生更新,但返回“未定义”一词,这是唯一返回的内容,打印在页面的左上角。

我已经仔细检查了我的所有变量是否都已定义,所以我不知道这可能指的是什么。

下面是我的更新查询代码。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Add Beer for Brew Log</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<style type="text/css">
.standardfont {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 12px;
}
</style>
</head>
<?
include "dblogin.php";//database connection

$ID = $_POST['ID'];
$Beer = $_POST['Beer'];
$BrewDate = $_POST['BrewDate'];
$EndOfPrimary = $_POST['EndOfPrimary'];
$EndOfSecondary = $_POST['EndOfSecondary'];
$PackagingDate = $_POST['PackagingDate'];
$AnticipatedOG = $_POST['AnticipatedOG'];
$MashDuration = $_POST['MashDuration'];
$MashRatio = $_POST['MashRatio'];
$MashTempTarget = $_POST['MashTempTarget'];
$StrikeWaterTemp = $_POST['StrikeWaterTemp'];
$StrikeWaterVolume = $_POST['StrikeWaterVolume'];
$MashTempActualStart = $_POST['MashTempActualStart'];
$MashTempActualEnd = $_POST['MashTempActualEnd'];
$FirstRunningsVolume = $_POST['FirstRunningsVolume'];
$FirstRunningsGravity = $_POST['FirstRunningsGravity'];
$SpargeType = $_POST['SpargeType'];
$Infusion2Volume = $_POST['Infusion2Volume'];
$Infusion2Temp = $_POST['Infusion2Temp'];
$Infusion2MashTemp = $_POST['Infusion2MashTemp'];
$Infusion2RunningsVolume = $_POST['Infusion2RunningsVolume'];
$Infusion2RunningsGravity = $_POST['Infusion2RunningsGravity'];
$Infusion3Volume = $_POST['Infusion3Volume'];
$Infusion3Temp = $_POST['Infusion3Temp'];
$Infusion3MashTemp = $_POST['Infusion3MashTemp'];
$Infusion3RunningsVolume = $_POST['Infusion3RunningsVolume'];
$Infusion3RunningsGravity = $_POST['Infusion3RunningsGravity'];
$SG = $_POST['SG'];
$MashEfficiency = $_POST['MashEfficiency'];
$BoilDuration = $_POST['BoilDuration'];
$Finings = $_POST['Finings'];
$OG = $_POST['OG'];
$VolumePreboil = $_POST['VolumePreboil'];
$VolumePostBoil = $_POST['VolumePostBoil'];
$VolumeInFermenter = $_POST['VolumeInFermenter'];
$FermCheck1Date = $_POST['FermCheck1Date'];
$FermCheck1Temp = $_POST['FermCheck1Temp'];
$FermCheck1Gravity = $_POST['FermCheck1Gravity'];
$FermCheck2Date = $_POST['FermCheck2Date'];
$FermCheck2Temp = $_POST['FermCheck2Temp'];
$FermCheck2Gravity = $_POST['FermCheck2Gravity'];
$FermCheck3Date = $_POST['FermCheck3Date'];
$FermCheck3Temp = $_POST['FermCheck3Temp'];
$FermCheck3Gravity = $_POST['FermCheck3Gravity'];
$FG = $_POST['FG'];
$PackagingType = $_POST['PackagingType'];
$CarbonationType = $_POST['CarbonationType'];
$CarbonationVolume = $_POST['CarbonationVolume'];
$Notes = $_POST['Notes'];

$query = "UPDATE brewlog 
          SET   EndOfPrimary='$EndOfPrimary',
                EndOfSecondary='$EndOfSecondary',
                PackagingDate='$PackagingDate',
                AnticipatedOG='$AnticipatedOG',
                MashDuration='$MashDuration',
                MashRatio='$MashRatio',
                MashTempTarget='$MashTempTarget',
                StrikeWaterTemp='$StrikeWaterTemp',
                StrikeWaterVolume='$StrikeWaterVolume',
                MashTempActualStart='$MashTempActualStart',
                MashTempActualEnd='$MashTempActualEnd',
                FirstRunningsVolume='$FirstRunningsVolume',
                FirstRunningsGravity='$FirstRunningsGravity',
                SpargeType='$SpargeType',
                Infusion2Volume='$Infusion2Volume',
                Infusion2Temp='$Infusion2Temp',
                Infusion2MashTemp='$Infusion2MashTemp',
                Infusion2RunningsVolume='$Infusion2RunningsVolume',
                Infusion2RunningsGravity='$Infusion2RunningsGravity',
                Infusion3Volume='$Infusion3Volume',
                Infusion3Temp='$Infusion3Temp',
                Infusion3MashTemp='$Infusion3MashTemp',
                Infusion3RunningsVolume='$Infusion3RunningsVolume',
                Infusion3RunningsGravity='$Infusion3RunningsGravity',
                SG='$SG',
                MashEfficiency='$MashEfficiency',
                BoilDuration='$BoilDuration',
                Finings='$Finings',
                OG='$OG',
                VolumePreboil='$VolumePreboil',
                VolumePostBoil='$VolumePostBoil',
                VolumeInFermenter='$VolumeInFermenter',
                FermCheck1Date='$FermCheck1Date',
                FermCheck1Temp='$FermCheck1Temp',
                FermCheck1Gravity='$FermCheck1Gravity',
                FermCheck2Date='$FermCheck2Date',
                FermCheck2Temp='$FermCheck2Temp',
                FermCheck2Gravity='$FermCheck2Gravity',
                FermCheck3Date='$FermCheck3Date',
                FermCheck3Temp='$FermCheck3Temp',
                FermCheck3Gravity='$FermCheck3Gravity',
                FG='$FG',
                PackagingType='$PackagingType',
                CarbonationType='$CarbonationType',
                CarbonationVolume='$CarbonationVolume',
                Notes='$Notes'            
          WHERE ID='$ID'";
$result = mysql_query($query) or die(mysql_error());
?>
Done.
4

1 回答 1

1

您显然是在尝试使用 MySQL,却不知道如何安全地使用它(或者根本不知道 :))。

我建议学习 MySQL 或使用一些 ORM - 你会发现它们可以帮助你专注于编写逻辑而不是繁琐的查询编写......

我所知道的最好的 ORM 是 RedBeanPHP——它小巧、快速且易于使用。

它也很灵活-您不必在开发之前设计数据库布局,需要在表中添加字段吗?没问题只是$object->newfield="hi!";

它与数据库无关 ( :D ) - 如果您的客户选择切换到 PostgreSQL 左右,您可以使用一行代码进行迁移。

http://redbeanphp.com/试试看。

于 2013-05-11T16:59:09.047 回答