Incorrect date value error message

I am a student currently learning PHP and SQL.

We are building a PHP form and the input values need to be inserted into a MySQL database. (I am using PhpMyAdmin.)

When I load the page, I just see this error, and my teacher said he is not familiar with how to fix it!

“Database update failed.Incorrect date value: ‘dateOfRelease’ for column ‘ReleaseDate’ at row 1”

The name of the column in my database that I am trying to insert the date into is called ReleaseDate, with a data type of ‘date’.

I am using the html input type ‘date’ in my form. The input field is named ‘dateOfRelease’.

I have uploaded the code I have so far, I hope someone can help. (I realise this code must be all over the place, as I have followed quite a few tutorials on YouTube, and everyone seems to have different ways of making a php form that inserts values into a database!)

This is all very new to me, so please be nice!

Thanks,

Zara


addMovieForm.txt (14.5 KB)

You don’t just drop variables into queries. You use parameterized statements to insulate your database.

The reason for your error,
[php]$dateOfRelease = “dateOfRelease”;[/php]
Where do you see a date for the date column type?

You have another issue, if any of those queries fail, you have orphaned records. Why is your instructor not having you wrap those in a transaction, and why all the individual statements? Do one, do another, do another. Not, line them all up and drop them at interval.

Yikes OP! Is that what they are teaching in school these days?

The whole concept is wrong. You should not be inserting all those pieces of data every time you add a new movie.

Adding Directors is its own complete separate action as is the genre, producers, nationalities, stars and distributors.

When adding a new movie, the aforementioned items should be selected from a dropdown of data already in the DB. In the case that say, a particular director has never been added, THEN you click on your Add New Director link returning back to just adding the movie table data. Same for the others mentioned. There is no need to get into transactions when you have it properly set up unless of course EVERY time you add a new movie all the related data is unique for every movie which just isn’t going to be the case.

Sponsor our Newsletter | Privacy Policy | Terms of Service