我从Javascript
发送的变量得到0(零)值$query= "SELECT Name,Lastname FROM %s s, %s v, %s k WHERE s.FK_ID_user=%d AND s.Reg_id=%d AND s.Reg_id=k.Reg_id
AND v.ID_user= s.FK_ID_user AND DATE(s.Time) BETWEEN '%d-%d-%d' AND '%d-%d-%d'";
$query = sprintf($query,$_SESSION['SESS_MAIN_BASE'],$_SESSION['SESS_USER_BASE'],$_SESSION['SESS_REG_BASE'],$id_user,$reg_id,$d_year1 ,$d_month1,$d_day1,$d_year2,$d_month2,$d_day2);
来自Javascript:
$.ajax({
type: 'POST',
url: 'history.php',
data: {
'id_user':$('#select-choice-user').val(),
'reg_id':$('#select-choice-reg').val(),
'd_year1':$('#select-choice-year1').val(),
'd_month1': $('#select-choice-month1').val(),
'd_day1':$('#select-choice-day1').val(),
'd_year2':$('#select-choice-year2').val(),
'd_month2': $('#select-choice-month2').val(),
'd_day2':$('#select-choice-day2').val()
},
success: function(data)//callback to be executed when the response has been received
});
这是PHP的一部分:
$id_user= $_POST['id_user'];
$reg_id= $POST['reg_id'];
$d_year1=$POST['d_year1'];
$d_month1=$POST['d_month1'];
$d_day1=$POST['d_day1'];
$d_year2=$POST['d_year2'];
$d_month2=$POST['d_month2'];
$d_day2=$POST['d_day2'];
问题是所有使用POST值发送的值都设置为0,我可以在post方法中看到数据是正常发送的,值是这样的:
id_user:0010282658
reg_id:951
d_year1:2012
d_month1:05
d_day1:7
d_year2:2012
d_month2:10
d_day2:6
答案 0 :(得分:8)
确保您正在阅读$ _POST而不是$ POST