adding error handling
<p>i have a big favor to ask i been trying for the past month to add error handling to this script with no luck what so ever can anyone here please help me out with this i tried everything i know im trying to add if the files where upload it will echo and say it was and if the file boxes are empty echo saying its empty if anyone can help it would be great thanks...</p>

<pre><code>$MaxSize = "600000";

if (isset($_POST['btn_update'])){
    function createRandomPassword() {
        $chars = "abcde!@#%^fghijkmnoABCDEFGHIJKpqrstuvwxyz023456789ABCDEFGHIJKLMNOPQRSTUVWZ!@#%^&amp;";
        srand((double)microtime()*10000000);
        $i = 0;
        $pass = '' ;

       while ($i &lt;= 19) {
           $num = rand() % 60;
           $tmp = substr($chars, $num, 1);
           $pass = $pass . $tmp;
           $i++;
       }
       return $pass;
    }  

    if ($_FILES['aMyUploads0']['size'] &gt; $MaxSize || $_FILES['aMyUploads1']['size'] &gt; $MaxSize || $_FILES['aMyUploads2']['size'] &gt; $MaxSize)
    {
        echo "ERROR: File too big!";
        exit;
    }

    $allowed_filetypes = array(".jpg", ".gif", ".jpeg", ".png");
    $ext = substr($newLocation, strpos($newLocation,'.'), strlen($newLocation)-1);

    if(!in_array($ext,$allowed_filetypes))
    {
        die('The file you attempted to upload is not allowed.');
    }

    $aMyUploads = array();
    $password = createRandomPassword();

    foreach($_FILES as $aFile)
    {
        $newLocation = 'uploads/'.$password .$aFile["name"];
        if(0 === $aFile['error'] &amp;&amp; (false !== move_uploaded_file($aFile['tmp_name'], $newLocation)))
        {
            $aMyUploads[] = $newLocation;
        }
        else
        {
            $aMyUploads[] = '';
        }
    }

    $connection = mysql_connect("localhost", "??", "??");
    mysql_select_db("??", $connection);
    $insert = "INSERT INTO ALS_future_photos (??, ??, ??) VALUES 
                      (' ".$aMyUploads[0]." ',
                       ' ".$aMyUploads[1]." ', 
                       ' ".$aMyUploads[2]." ')";

    $add_member = mysql_query($insert) or die(mysql_error());
}
</code></pre>
