Personal Catalogue: PHP & MySQL — Chapter 8, Exercise 2 ==================================================== TASK Build bulk_add.php against your real database and paste in five book titles, one per line, including one title that's an exact duplicate of a book already in your catalogue from an earlier chapter. Confirm the results message correctly reports 4 added and 1 skipped, and that the database contains exactly one row for the duplicate title, not two. SOLUTION Assuming "Fluent Python" already exists in the catalogue as a book from an earlier chapter, submit bulk_add.php with Type set to "book" and the textarea containing: Fluent Python Clean Code The Pragmatic Programmer Refactoring Design Patterns Since "Fluent Python" is an exact match (same title, same item type) against an existing row, $checkStmt->execute() finds it and the loop adds it to $skipped instead of inserting it. The other four titles have no match and are inserted normally. The page should display: Added 4 item(s). Skipped 1 likely duplicate(s): Fluent Python Confirm at the mysql> prompt: SELECT COUNT(*) FROM items WHERE title = 'Fluent Python'; Expected output: 1 (not 2) — proving the duplicate check genuinely prevented a second insert, rather than the "skipped" message just being cosmetic while a duplicate row was created anyway. Also confirm the four new titles were actually inserted: SELECT title FROM items WHERE title IN ('Clean Code', 'The Pragmatic Programmer', 'Refactoring', 'Design Patterns'); Expected output: all four titles present, one row each. WHY THIS WORKS AS AN ANSWER ---------------------------- It deliberately includes a real, exact duplicate in the pasted batch to exercise the skip logic specifically, and verifies both halves of the outcome — the message reports the correct counts, and the database itself genuinely contains only one row for the duplicate title — rather than trusting the displayed message alone.