이것은 토요일을 소비했습니다. 도와주세요.한 필드에서 SQL UPDATE 문이 작동하지 않습니다.
GoDaddy 공유 계정에서 호스팅되는 MySQL 데이터베이스 테이블의 레코드를 업데이트해야하는 큰 형식이 있습니다. 양식을 제출할 때 업데이트하려고하는 18 개의 레코드가 있지만 지금까지는 17 개 밖에 없었습니다. 마지막 필드 인 "blackTowellCount"는 UPDATE 문에 포함시킬 때 문제를 일으 킵니다.
해당 필드를 SQL 문에서 제외하면 ALL 18 필드가 성공적으로 PHP 파일에 POST되고 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());
}
1. 코드가 너무 많습니다. 필요한 것을 게시하십시오. 2. 오류를 확인하지 않습니다. PHP와 MySQL은 무엇이 잘못 되었는가를 듣고 자합니다. 3. SQL 인젝션에 대해 열려 있습니다. –
오류보고/시도/캐치 – Drew
1. 복사 2. 어떻게하는지 모르지만, 그것. 3. 이걸 좀 더 설명 할 수 있니? 나는 단지 배우려고 노력하고있다. –