MySQL UPDATE查询返回单词“Undefined”

时间:2013-05-11 16:50:38

标签: php mysql

我正在做一个MySQL更新语句,当我点击提交时,更新发生了,但是返回了单词“undefined”,这是唯一返回的内容,打印在页面的左上角。

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

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

    <!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.

1 个答案:

答案 0 :(得分:1)

你显然试图在没有知识的情况下使用MySQL如何安全地(或者根本就是:) :)。

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

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

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

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

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