Debug Your Code
1. The URL http://sunlabX.njit.edu/~<ucid>/...( where X = 31-35 and <ucid> = your UCID) can be used as an aid to help debug your code. The Apache Web server log files access_log and error_log that correspond to the above URL are located in /export/apache/logs on sunlab31.njit.edu - sunlab35.njit.edu. You can search through these log files to help debug your code.
The Apache-PHP running on the sunlabX listed above is the same as that running on web.njit.edu. The URLs listed above are accessible only from within the NJIT network - i.e., from on the NJIT campus, or via VPN.
Note: For security reasons, errors that occur during the execution of PHP code are not displayed as a part of the output. As a workaround, see Alternate Method below.
Example of Using Log Files
Assume that that your UCID is "abc123", your program is titled "homework4.php", and you use sunlab5.njit.edu to debug it.
- When you log in, the file is "public_html/homework4.php", or extended "/sunlab/cad/a/b/abc123/public_html/homework4.php".
- The URL will be "http://sunlab5.njit.edu/~abc123/homework4.php"
-
You could find error messages on sunlab5.njit.edu with these commands:
cd /export/apache/logs grep abc123/public_html/homework4.php access_log error_log - The last message displayed would be from your last attempt to use the script.
Some types of syntax errors can be easily found by running a test of your PHP script from the system command line with the "php" (/usr/local/bin/php) command. For the example given above, the command would be:
cd $HOME/public_html php homework4.php This would display the same error message as shown in the example. However if your script has no errors, all the HTML generated by the script will be displayed on your screen, and you might be prompted for input variables. Press CTRL-C to exit "php", and use the first technique for additional debugging.


Information Services and Technology