我有JS代码,它由以下形式调用:
//////////////// About Tab
$(document).ready(function(){
$("form#FanDetail").submit(function() {
// store the values from the form input box, then send via ajax below
var bio = $('#bio').val();
var dob = $('#dob').val();
var zip = $('#actualZip').val();
var occup = $('#actualOccup').val();
var fbkurl = $('#fbkurl').val();
var twiturl = $('#twiturl').val();
var phoNum = $('#phoNum').val();
$.post(
"../src/php/registration/about/submitvalues_about_tab.php",
$("form#FanDetail").serialize(),
function(){
$('form#FanDetail').hide(function(){
$('div.success').fadeIn();
});
});
return false;
});
});
由js调用的Php代码:
///////////////////////////////////////////////
######## Get Input to Submit ############## //
///////////////////////////////////////////////
$fanBio=$_POST['bio'];
$fanDob=$_POST['dob'];
$zipval=$_POST['zip'];
$occupval=$_POST['occup'];
$facebookurl=$_POST['fbkurl'];
$twitterurl=$_POST['twiturl'];
$phoneNum=$_POST['phoNum'];
$fanID=1;
try{
//$sessionvar = session_id();
### DB Connection already established above.
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth = $dbh->prepare("
UPDATE Fan
SET fanBio=:fanBio,fanDob=:fanDob,fanDetLocID=:zipval,occupID=:occupval,fanFbk=:facebookurl,fanTwit=:twitterurl,fanPho=:phoneNum
WHERE fanID=:fanID
");
$sth->bindParam(':fanBio', $fanBio);
$sth->bindParam(':fanDob', $fanDob);
$sth->bindParam(':zipval', $fanZip);
$sth->bindParam(':occupval', $fanOccup);
$sth->bindParam(':facebookurl', $fanFbk);
$sth->bindParam(':twitterurl', $fanTwit);
$sth->bindParam(':phoneNum', $fanPhone);
$sth->bindParam(':fanID', $fanID);
$sth->execute(array(':fanBio' => $fanBio,':fanDob' => $fanDob,':zipval' => $zipval,':occupval' => $occupval,':facebookurl' => $facebookurl,':twitterurl' => $twitterurl,':phoneNum' => $phoneNum,':fanID' => $fanID));
$sth->debugDumpParams(); ## debugging query
}
catch(PDOException $e){
echo "ERROR HAS HAPPENED CATCH{}";
file_put_contents('../../../../PDODBConnectionErrors.txt','ERROR: [submitvalues_about_tab.php] about '.$e->getMessage(), FILE_APPEND);
}
** RAW HTML Code **
<form method="post" id="FanDetail">
<textarea id="bio" name="fan_bio" cols="27" rows="3"></textarea><br />
<input id="dob" name="fan_dob" value="(e.g. 01/05/1965)" onFocus="clearText(this)" /><br />
<div class="ui-widget">
<input id="zip" name="term" value="What is your Zipcode?" onFocus="clearText(this)" /><br />
<input id="actualZip" type="hidden" name="actualzipval" value="" />
</div><!--ui-widget :: zip -->
<div class="ui-widget">
<input id="occup" type="text" name="term2" value="e.g. Computer Programmer, etc" onFocus="clearText(this)" /><br />
<input id="actualOccup" type="hidden" name="actualOccupval" value="" />
</div><!--ui-widget :: occup -->
<input id="fbkurl" type="text" name="fan_fbk" value="e.g. SportsFan12" onFocus="clearText(this)" /><br />
<input id="twiturl" type="text" name="fan_twit" value="e.g. AboutSports2012" onFocus="clearText(this)" /><br />
<input id="phoNum" type="text" name="fan_pho" value="cell or home phone" onFocus="clearText(this)" /><br />
<input style="background-image:url('img/save.png');" type="submit" name="saveAbout" value="" id="submit" />
</form>
<div class="success" style="display:none;">Got it!</div>
我最初尝试使用:
Positioned Placeholders
:没有成功(获得如下所述的相同错误)UPDATE
Fan
,并且工作正常。catch{} block
(未显示)输出 SQL:[165] 更新范 SET fanBio =:fanBio,fanDob =:fanDob,fanDetLocID =:zipval,occupID =:occupval,fanFbk =:facebookurl,fanTwit =:twitterurl,fanPho =:phoneNum WHERE fanID =:fanID
Params: 8
Key: Name: [7] :fanBio
paramno=-1
name=[7] ":fanBio"
is_param=1
param_type=2
Key: Name: [7] :fanDob
paramno=-1
name=[7] ":fanDob"
is_param=1
param_type=2
Key: Name: [7] :zipval
paramno=-1
name=[7] ":zipval"
is_param=1
param_type=2
* 问题是,它仍然没有更新行,但它通过调用$sth->debugDumpParams();
* 给我回复它给我上面的输出^^。这种反应有问题吗?请记住try{}
中的文件为空,没有写入错误。