这已经消耗了我的星期六。请帮忙。
我有一个大表单,我需要更新GoDaddy共享帐户上托管的MySQL数据库表中的记录。在提交表单时,我有18条记录试图更新,但到目前为止,我只有17条记录。当我将其包含在UPDATE语句中时,倒数第二个字段" blackTowellCount"会导致问题。
如果从SQL语句中排除有问题的字段,则所有18个字段都成功将数据发送到PHP文件,并且SQL语句中列出的17个字段上传就好了。当我包含blackTowellCount字段时,UPDATE停止工作,表单不再将数据发送到PHP表单。 WTF?!
您还会注意到,这里有一个几乎相同的字段," whiteTowellCount"更新就好了。
表单的一部分:
<div class="well">
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-2">
<label for="blackTowellCount" class="pull-right">Black Towells</label>
</div>
<div class="col-md-3">
<input type="text" class="form-control" id="blackTowellCount" name="blackTowellCount" placeholder="black towell #"/>
</div>
<div class="col-md-2">
<label for="whiteTowellCount" class="pull-right">White Towells</label>
</div>
<div class="col-md-3">
<input type="text" class="form-control" id="whiteTowellCount" name="whiteTowellCount" placeholder="white towell #"/>
</div>
<div class="col-md-1">
</div>
</div>
</div>
功能SQL:
$addIntakeSQL = mysqli_query($link,"UPDATE Act SET w9FilePath='".$w9Upload_destination."', riderFilePath='".$riderUpload_destination."', hospRiderFilePath='".$hospRiderUpload_destination."', inputFilePath='".$inputListUpload_destination."', stageFilePath='".$stagePlotUpload_destination."', backlineFilePath='".$backlineUpload_destination."', bathTowellCount='".$bathTowellCount."', breakfastCount='".$breakfastCount."', lunchCount='".$lunchCount."', dinnerCount='".$dinnerCount."', breakfastRestriction='".$breakfastRestriction."', lunchRestriction='".$lunchRestriction."', dinnerRestriction='".$dinnerRestriction."', arrivalDate='".$arrivalDate."', arrivalTime='".$arrivalTime."', needTransport='".$needTransport."', whiteTowellCount='".$whiteTowellCount."' WHERE actID='".$actID."'") or die (mysqli_error());
破解SQL:
$addIntakeSQL = mysqli_query($link,"UPDATE Act SET w9FilePath='".$w9Upload_destination."', riderFilePath='".$riderUpload_destination."', hospRiderFilePath='".$hospRiderUpload_destination."', inputFilePath='".$inputListUpload_destination."', stageFilePath='".$stagePlotUpload_destination."', backlineFilePath='".$backlineUpload_destination."', bathTowellCount='".$bathTowellCount."', breakfastCount='".$breakfastCount."', lunchCount='".$lunchCount."', dinnerCount='".$dinnerCount."', breakfastRestriction='".$breakfastRestriction."', lunchRestriction='".$lunchRestriction."', dinnerRestriction='".$dinnerRestriction."', arrivalDate='".$arrivalDate."', arrivalTime='".$arrivalTime."', needTransport='".$needTransport."', blackTowellCount='".$blackTowellCount."', whiteTowellCount='".$whiteTowellCount."' WHERE actID='".$actID."'") or die (mysqli_error());
.PHP文件的一部分:
$bathTowellCount = $_POST['bathTowellCount'];
$breakfastCount = $_POST['breakfastCount'];
$lunchCount = $_POST['lunchCount'];
$dinnerCount = $_POST['dinnerCount'];
$breakfastRestriction = $_POST['breakfastRestriction'];
$lunchRestriction = $_POST['lunchRestriction'];
$dinnerRestriction = $_POST['dinnerRestriction'];
$arrivalDate = $_POST['arrivalDate'];
$arrivalTime = $_POST['arrivalTime'];
$needTransport = $_POST['needTransport'];
$blackTowellCount = $_POST['blackTowellCount'];
$whiteTowellCount = $_POST['whiteTowellCount'];
$addIntakeSQL = mysqli_query($link,"UPDATE Act SET w9FilePath='".$w9Upload_destination."', riderFilePath='".$riderUpload_destination."', hospRiderFilePath='".$hospRiderUpload_destination."', inputFilePath='".$inputListUpload_destination."', stageFilePath='".$stagePlotUpload_destination."', backlineFilePath='".$backlineUpload_destination."', bathTowellCount='".$bathTowellCount."', breakfastCount='".$breakfastCount."', lunchCount='".$lunchCount."', dinnerCount='".$dinnerCount."', breakfastRestriction='".$breakfastRestriction."', lunchRestriction='".$lunchRestriction."', dinnerRestriction='".$dinnerRestriction."', arrivalDate='".$arrivalDate."', arrivalTime='".$arrivalTime."', needTransport='".$needTransport."', whiteTowellCount='".$whiteTowellCount."' WHERE actID='".$actID."'") or die (mysqli_error());
}
答案 0 :(得分:1)
嗨首先,因为所有人都建议您的代码向SQL injections
开放,请改用PDO
。第二个php的功能是显示错误,包括它们,如果你不想做的话。
在页面顶部添加这些行
error_reporting(E_ALL);
ini_set('display_errors',1);
你还没有给mysqli_error()
个参数
将die(mysqli_error());
替换为die(mysqli_error($link));
答案 1 :(得分:0)
There was a space in front of "blackTowellCount" in the database. I hate programming.