Homework 6 (Kevin Bacon) FAQ

Q: On the spec, you say that I can be creative and make up my own page appearance and layout. So I can make it look absolutely any way I want?
A: As long as it follows the guidelines on the spec. And, practically speaking, the TAs need to be able to grade it, so please don't put anything too weird in there, such as a bunch of videos or animations that are hard to load and see clearly.
Q: Is it okay for me to completely copy the layout from the expected output images, right?
A: Sure, if you want.
Q: Why can't my code connect to webster? It says, Access denied for user 'MYUWNETID'@'webster.cs.washington.edu' (using password: YES)
A: When you construct your new PDO object, use the server name "localhost", not "webster.cs.washington.edu". Also make sure you don't have any spaces in the connection string, and that you spell everything exactly right.
Q: Why don't my queries work in PHP?
A: Lots of students have small syntax problems in their SQL queries. The best way to find and fix them is to use the SQL Query Tester located here. It will tell you if your query has any syntax errors. Ask a TA if you don't understand the error messages. Once your query works in the tester, just wrap it in quotes as a PHP string and you're nearly there.

If your query works in the tester but not in PHP, try to print() the query before you run it. Then copy/paste the printed text into the tester and try to run it there. Often you'll discover you are missing quotes or a semicolon or some other small syntax problem. Also enable exceptions in your PDO object (as described in the textbook and lecture slides) so that if anything is going wrong, you will see an error on the page.

Q: What if an actor hasn't been in any films at all?
A: You may assume that this won't happen. If they're in the actors table, assume that they have been in at least one movie.
Q: When I try to do a foreach loop over my $rows, nothing happens.
A: One weird thing about the $rows object (which behaves somewhat like an array, but is actually an object of type PDOStatement) is that you can only do one foreach over its rows. If you try to foreach over it a second time, no rows will be there. The first foreach loop "consumes" the rows as it returns them, sort of like an iterator. You'll need to find a solution that doesn't use two foreach loops over the same $rows object.
Q: How do I remove redundancy between pages?
A: Put common code in common.php. See the provided index.php code as an example.
Q: When there is an "actor not found" or "actor has not appeared in any movies with Kevin Bacon" error, does my page still have to be W3C valid?
A: Yes, it should. If an error makes you want to abort your page, make sure to still output the bottom page content, like the search forms and </body> and so on.
Valid HTML5 Valid CSS JavaScript Lint
This document and its content are copyright © Marty Stepp, 2013. All rights reserved. Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form is prohibited without the author's expressed written permission.