| CS 199 | Willamette University | Spring, 2019 |
|
Programming in PHP, Databases with MySQL, and Web Applications |
||
For CS199, HTML. CSS, and PHP must be placed on cs-199.willamette.edu, in order to be run appropriately. Work on this server may involve
placing files in a directory, so they can be viewed over the Web, and
running PHP programs in a terminal window to make initial checks regarding syntax and partial program execution.
In practice, access to these files and directories proceeds in different ways for these two types of work.
In order for a file for the course to be accessed over the Web, it must be copied to the cs-199.willamette.edu server. The specific location for the file depends upon context.
Work done with a partner should be placed in a "shared" directory, which is accessible to all class members.
Work done individually (and not to be shared) should be placed in a directory identified by your username (e.g., used when you log in or when you send/receive your email).
The process for both locations is largely the same, with a simple adjustment in specifying a directory. The steps below apply to Mac OS X computers (e.g., those in the classroom). Steps for Windows machines are similar (but see WITS for details).
Find the file(s) to be copied on your Desktop, or use the Finder to locate your file(s) on your local machine.
Open a separate Finder window (in the Finder options a the top of the screen, goto File, and then "New Folder").
Again, in the Finder, use the "Go" option, and select "Connect to Server".
When a new window appears, enter the following connection string:
With a Finder window open for the file(s) on your local machine, and another window open on the cs-199 server, highlight the desired files on your local file(s) and drag them to the cs-199 folder window.
If a PHP file contains a syntax or otherwise encounters an error when it is run, the entire PHP environment crashes, and the Web browser likely shows a blank screen. Unfortunately, this blank screen indicates that something is wrong, but provides little insight regarding the nature of the problem or how to fix it.
Fortunately, many issues of syntax and simple processing may be identified by running the file with PHP directly, separate from a browser. Steps for this work follow.
Click on the Terminal window icon (a black square containing a >_
symbol). This opens a new window in which one can type commands.
(As above, in what follows, username is the designation used for your login
name, which is also your email name at willamette.edu.)
In the Terminal window, log into Willamette servers by typing
ssh username@cs-199.willamette.edu
You will be asked for your Willamette University password.
After logging in, you need to indicate what directory you wish to access.
cd /var/www/html/shared
cd /var/www/html/username
Note: In this command, "cd" stands for "change directory"—that is, you are moving to the designated directory.
Assuming you have previously stored the PHP program "prog.php" in this directory, you may run this program by typing
php prog.php
If syntactical errors are present, they will be reported, together with the line number where they were found. (Note that the line number may be off by 1 or 2, due to the nature of how the php command works. In any case, the trouble likely will be close to the line number printed.)
When the line number of an error is identified, open the file with TextEdit, and use Command+l (lower case L) to enter the line number reported.
When you run the program, you do not have access to any data typed into a form, so any fields from a form are considered blank. This lack of data may not help you in examining output from a form. However, in trying to run the program, the php command will print any identified errors in program syntax. A few additional issues also may be found (e.g., the program is trying to access a file that does not exist). Once you know that the program is syntactically valid, then you can work with the program in a browser to check actual processing.
|
created 6 February 2019 revised 6 February 2019 |
|