Prev | Current Page 54 | Next

Larry Ullman

"Building a Web Site with Ajax: Visual QuickProject Guide"

strong>

??™;
mysql_close($dbc);
??¦
adding records 53
report any errors
1 The fi rst else clause applies if the query did not result in one a?¬? ected
row. This would normally be the result of a syntax error. (See extra bits
on page 58.)
2 The second else clause
applies if the data didn??™t pass
all the validation tests.
3 Because the errors are
stored in an array, looping
through them is the easiest
way to access them all.
??¦
echo ???

The employee has been added.strong>

??™;
} else { // Query failure.
echo ???

The employee could not be
added due to a system error.

??™;
}
} else { // Errors!
echo ???

The following errors occurred:

class=???error???>??™;
foreach ($errors as $e) {
echo ???
  • Please enter a valid $e.
  • \n???;
    }
    echo ?????™;
    }
    mysql_close($dbc);
    ??¦
    Finally, indicate to the user what problems occurred, if applicable.
    54 adding records
    test the non-Ajax version
    1 Load the HTML page in your Web browser to test what we??™ve
    created so far.
    The address must begin with http://
    for this to work.
    3 The PHP page should show the results.


    Pages:
    42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66