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.";
  1. When i try to update, the level gets updated but not the leveldescription.
  2. Also level is unique, but it does not throw error when i enter duplicate value.. though the DB is not getting affected.

1 Answer 1

1

Your code seem to be fine, Have u checked whether $levDes have some values or not before query. echo the query or $levDes.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks i missed it in Flex... while dispatching

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.