Doing a roll back with multiple MySQLI prepared statement
function CreateNewAccount(&amp;$newRegistrationDataArray){ ///note the &amp;


    /* variable needed */
    $memberId = $this-&gt;generateMemberId(); // a private function that generate member id

    // that is lots of repetitive code, lazy way is use extract,
    // although can be dangerous if you can't trust data in $newRegistrationDataArray
    extract($newRegistrationDataArray);

//    $date = $newRegistrationDataArray['date'];
//    $name = $newRegistrationDataArray['name'];
//    $address = $newRegistrationDataArray['address'];
//    $country = $newRegistrationDataArray['country'];
//    $occupation = $newRegistrationDataArray['occupation'];
//    $emailAddress = $newRegistrationDataArray['emailAddress'];
//    $usename = $newRegistrationDataArray['usename'];
//    $password = $newRegistrationDataArray['password'];
//    $salt = $newRegistrationDataArray['salt'];
//    $secretQuestion = $newRegistrationDataArray['secretQuestion'];
//    $secretAnswer = $newRegistrationDataArray['secretAnswer'];
//    $transactionCode = $newRegistrationDataArray['transactionCode'];
//    $perfectMoneyAccount = $newRegistrationDataArray['perfectMoneyAccount'];
//    $egoPayAccount = $newRegistrationDataArray['egoPayAccount'];
//    $payeerAccount = $newRegistrationDataArray['payeerAccount'];
//    $okPayAccount = $newRegistrationDataArray['okPayAccount'];
//    $bitcoinAccount = $newRegistrationDataArray['bitcoinAccount'];
//    $upline = $newRegistrationDataArray['upline'];
//    $userRegistrationIp = $newRegistrationDataArray['userRegistrationIp'];
//    $status = $newRegistrationDataArray['status'];
    /* variable needed */


    try
    {
        /* set autocommit to off */
        $this-&gt;dbConnection-&gt;autocommit(FALSE);

        $stmt1=$this-&gt;dbConnection-&gt;prepare("INSERT INTO `members` (date,name,address,country,occupation,emailAddress,memberID,usename,password,salt,secretQuestion,secretAnswer,transactionCode,perfectMoneyAccount,egoPayAccount,payeerAccount,okPayAccount,bitcoinAccount,upline,userRegistrationIp,status) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
        $stmt1-&gt;bind_param('sssssssssssssssssssss',$date,$name,$address,$country,$occupation,$emailAddress,$memberID,$usename,$password,$salt,$secretQuestion,$secretAnswer,$transactionCode,$perfectMoneyAccount,$egoPayAccount,$payeerAccount,$okPayAccount,$bitcoinAccount,$upline,$userRegistrationIp,$status);

        // failure is unexpected, so lets use exceptions to handle it
        if ($stmt1-&gt;execute() == false) {
            throw new Exception('Statement 1 Failed');
        }

        $stmt2=$this-&gt;dbConnection-&gt;prepare("INSERT INTO `membertotalfinancialstatus` (memberId) VALUES (?)");
        $stmt2-&gt;bind_param('s',$memberId);

        if ($stmt2-&gt;execute() == false) {
            throw new Exception('Statement 2 Failed');
        }

        // tidy up
        $stmt1-&gt;close();
        $stmt2-&gt;close();

        // is it normal to close connection at this level? or do you leave it open for other requests
        $this-&gt;closeDBConn;
    }
    catch(Exception $e)
    {
        // any sort of exception and we should rollback?
        // either that or subclass exception and handle each exception type differently
        $this-&gt;dbConnection-&gt;rollback();

        // whats the point of this, just re-throw the same exception?
        // $error=$e-&gt;getMessage();
        // throw new Exception($error);
        throw $e;
    } finally {
       // if you have php 5.5 you can do your tidy up here, although if 
       // an exception has occured, you probably don't care about freeing stmt's as
       // they all end up in the garbage anyway

        // tidy up
        //$stmt1-&gt;close();
        //$stmt2-&gt;close();
    }

}