I want to delete some data use:
$dbc=mysql_connect(_SRV,_ACCID,_PWD) or die(_ERROR15.": ".mysql_error());
$db=mysql_select_db("qdbase",$dbc) or die(_ERROR17.": ".mysql_error());
switch(postVar('action')) {
case 'changedata':
changedata(postVar('id'),postVar('chlotno'),postVar('chrange'),postVar('chS'),postVar('chA'),postVar('chB'),postVar('chC'),postVar('chstatus'));
break;
case 'deldata':
deld开发者_JAVA技巧ata(postVar('delid'));
break;
}
function changedata($id,$chlotno,$chrange,$chS,$chA,$chB,$chC,$chstatus){
$ID = mysql_real_escape_string($id);
$Lot_no = mysql_real_escape_string($chlotno);
$Range = mysql_real_escape_string($chrange);
$S = mysql_real_escape_string($chS);
$A = mysql_real_escape_string($chA);
$B = mysql_real_escape_string($chB);
$C = mysql_real_escape_string($chC);
$Status = mysql_real_escape_string($chstatus);
$Lot_no=strtoupper($Lot_no);
$Range=strtoupper($Range);
$sql = "UPDATE inspection_report SET Lot_no = '".$Lot_no."', Range_sampling = '".$Range."', S = '".$S."', ";
$sql.= "A = '".$A."', B = '".$B."', C = '".$C."', Status = '".$Status."' ";
$sql.= "WHERE id = ".$ID;
echo $sql;
$result=mysql_query($sql) or die(_ERROR26.": ".mysql_error());
//echo $result;
mysql_close($dbc);
}
function deldata($id){
$ID = mysql_real_escape_string($id);
$sql = "DELETE FROM inspection_report WHERE id = '".$ID."'";
echo $sql;
$result=mysql_query($sql) or die(_ERROR26.": ".mysql_error());
//echo $result;
mysql_close($dbc);
}
I have not found any error message in this query and show "200,OK". But the data still exist (not deleted). Why its happen? Is there something wrong in my query?
echo $sql:DELETE FROM inspection_report WHERE id = ''
huft sorry...i have made a stupid mistake, this is my answer:
$('#balupdate').click(function() {
if ($("#editbaldata").valid()){
var params = $('#editbaldata').serialize();
$.ajax({
async : false,
cache : false,
data : params,
success: function(res) {
i miss the .serialize()
make sure that the $id variable is same case throughout, $id != $ID
postVar
is not a variable. Try to use $postVar
. If your postVar is a function, give us code of this function. I don't see a end of the switch
function.
Based on the echo $sql it looks like postVar('delid') is returning null.
You should check your code and see if 'delid' is what you're actually passing to your script or if there is some other reason why it isn't set.
How is 'delid' set?
In PHP $id and $ID are two different variables.
精彩评论