Courses Plus Student
Notice/Warning in preview after pasting text file in to data.php -- Found solution.
By the end of this video, after pasting the contents of the text document from Teacher's Notes as directed, my preview page is broken.
At 4:51 Alena highlights ALL code between the opening and closing php tags and presumably erases/replaces all of it with what's in the text file. The next time we see the top of the code, at 5:29, we see on line 2 "$catalog = ;" and on line 3 "//Books" ... while I understand "//Books" is commented out and doesn't make any difference, the "$catalog = ;" makes a world of difference, especially since it is NOT in the text document we've been directed to therefore it does NOT get added to the data.php file (which prior to pasting the text document had the "$catalog = ;" line but now doesn't since we erased/replaced everything between the opening and closing php tags) leading to the following errors being displayed in the preview:
"Notice: Undefined variable: catalog in /home/treehouse/workspace/catalog.php on line 33"
"Warning: Invalid argument supplied for foreach() in /home/treehouse/workspace/catalog.php on line 33".
Being a newbie I first checked my data.php code line 33 since that's the last file I modified... it doesn't contain "foreach"... however catalog.php line 33 does (as the errors indicate). So by omitting the "$catalog = ;" line from the top of the data.php file, everything is left undefined and broken. Add that line back in and BOOM. Things work.
The error confused me far longer than it should have.