If X function was not successful do Y
<p>I need to know if a function I have just run was not successful. Below is the function in question and how it executes.</p>

<p>I know how I can do this by setting a variable from within the function and checking if it exists but, not sure that's the best practice.</p>

<pre><code>//Update users function
function update($db, $fn, $ln, $email, $offers, $vlue, $responce)
{
    $stmt = $db-&gt;prepare("insert into kkt (fName_765, lName_765, email_765, signup_765, kkt_resp_765, stamp_765) values (:fname, :lname, :email, :signup, NOW())");

    $parameters = array(
        ':fname' =&gt; $fn,
        ':lname' =&gt; $ln,
        ':email' =&gt; $email,
        ':signup' =&gt; $offers);

    $stmt-&gt;execute($parameters);
    print $db-&gt;lastInsertId(); //show ID
    return true;
}


//Test Attributes
$fn = 'test';
$ln = 'test';
$email = 'tesst@test,com';
$offers = '1';

try {
    update($db, $fn, $ln, $email, $offers);
}
catch (PDOException $e) {
    echo "no update there is a slight problem " . $e-&gt;getMessage();
}
</code></pre>

<p>I will use the try catch to notify myself via email if it was not successful, but should I put the code I am going to show the user in here or is it best to write something else to keep it neater?</p>

<p>Thanks for all your comments - the final code is now over at CR: <a href="http://codereview.stackexchange.com/questions/21481/pdo-connection-prep-and-execute-in-there-own-functions">http://codereview.stackexchange.com/questions/21481/pdo-connection-prep-and-execute-in-there-own-functions</a></p>
