From the course: PHP: Object-Oriented Programming with Databases

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Validations and errors

Validations and errors

- [Narrator] Before we leave the topic of creating and updating records in the database, I want us to talk about validations and errors. This is a concept that we talked about in the PHP with MySQL essential training. The fundamental idea is that we want to have control over the quality of data that gets saved to the database. Not all data is necessarily acceptable, and we want to be able to control that so that we have control over what goes in and comes out of our application. One way to do that is with validations. We check to see if data meets our standards before we put it in the database. And if it doesn't, then we want to know what went wrong, and we want to tell the user about it so that they can fix the problem, and try to submit it again. So that's where validations and errors come in. The basic structure that we've been using for our validations is just that we're going to keep a list of the errors. So to start with, we'll have an array of errors, that's going to be empty…

Contents