So, I had to make some changes in order to get this to work correctly:
You can download the files here:
First, please notice that there is a file called alters.sql
This file contains statements that you need to run on your database.
Here was the issue. An author or a publisher can have more than one book. So putting a bookID in the authors or the publisher table is not good and will lead to many issues. Additionally, the way you were attemptint to perform inserts on those tables will never work.
Once you have run all of that SQL, you will be ready to use the changed files.
I changed the queries in each file to make certain that both the add and edit functionality works.
You had a minor issue where you were calling mysql_error when you are using mysqli. I corrected those for you.
The code should be pretty self-explanitory. Take note of the ON DUPLICATE KEY UPDATE statements. This states that if the author or the publisher already exists, we just want to get the ID of the existing author or publisher. That way, if you enter the name of an author or a publisher that is already in the database, the book will be associated to the existing records rather than create new ones.
You can immediately see the edit page work by tyin the URL in as "editBooks.php?id=1"
However, if you have a page somewhere that lists books, it probably isn't going to work after the database changes because of the change to the way that books are associated to authors and publishers. To fix this, go into editBooks.php and look at lines 130 - 141. This is the select statement to get the book information now that the tables have been corrected. Actually, the way that you had the tables was a violation of Normal Form, so if I hadn't fixed them, your instructor probably would have said something.
Let me know if you have any questions. I'm here to help.
Please remember to rate my answer. Thank you so much!