Access denied for user 'MYUWNETID'@'webster.cs.washington.edu' (using password: YES)
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.
If your query works in the console but not in PHP, try to print()
the query before you run it. Then copy/paste the printed text into the console 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.
Display all 794 possibilities? (y or n)
and doesn't run the query.
foreach
loop over my $rows
, nothing happens.
$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.
common.php
. See the provided index.php
code as an example.
</body>
and so on.