How to get your PHP program to work
- Use jEdit to write your program to take advantage of
color-coding. This will help you catch mistakes such as a mistyped
keyword.
- Don't write a large program all at once, write a little bit at
a time. Test your program after every time you change or add
something.
- To test, upload your file to your public_html (or its subfolder)
on
rynite. Type in its URL in the browser. If you get a file-not-found
error, double-check the file name and its location.
- If the result is not what you expected and you don't immediately
see a mistake, you can try to run the program directly on the server
in a hope that you get some helpful information from the error
messages:
- login to rynite using
ssh
. In the lab type ssh
rynite
(or ssh yourusername@rynite
if
your user name is different on rynite) in the terminal window. Enter
the password. On your home machine (Windows) you can install putty
- a simple program that allows you to connect to a server via ssh.
- Change the directory to where your file is located using
cd
command, for instance cd
public_html/lab4
.
- Type
php myfile.php
(where instead of
myfile.php
you use the actual file name). This will give
the HTML output of the program (if any) and error messages (if
any). Some error messages are not very clear, but they usually give
you at least some idea of what's wrong and point to a specific line in
your program where the mistake was detected.
- Correct the mistake in jEdit and upload your file again.