0
$id=mysql_real_escape_string($levelid);
$l=mysql_real_escape_string($level);
$levDes=mysql_real_escape_string($leveldescription);
$sql="UPDATE `levels` SET level='$l',leveldescription='$levDes' WHERE id='$id' LIMIT 1";
$result=mysql_query($sql);
if(!$result){throw new Exception(mysql_error());}
$effectedRows=mysql_affected_rows();
if(!$effectedRows){
$sql="SELECT * FROM `levels` WHERE level='$l' AND id='$id' LIMIT 1";
$result=mysql_query($sql);
if(!$result){throw new Exception(mysql_error());}
if(mysql_num_rows($result)==0){
throw new Exception("Could not find Level's record in database to update.");
}else{//no changes to the row
return "Level successfully updated in database although no changes were detected.";
}//else
}//if
return "Level successfully updated in database.";
- 當我嘗試更新,水平得到更新,但不是leveldescription。
- 水平也是獨一無二的,但是當我輸入重複值時它不會拋出錯誤。雖然數據庫沒有受到影響。
謝謝我在Flex中錯過了......在調度時 – Kevin