PHP Troubleshooting
Questions about the coursework
Changes to the coursework description
Questions about the exam
PHP Troubleshooting
- It doesn't work, but it doesn't produce an error either.
Have a look at the source of the page via your browser ("View source"
or "View page source") for more details. Also:
Turn error reporting on. Add "error_reporting(E_ALL);" in the line after your
first "<?php". Some of the errors it shows are just warnings that you
can ignore. But it might give you more hints about the problem.
- Invisible control characters
If you copy and paste code on a PC, you sometimes encounter some
invisible control characters because of the differences between
PCs and Unix and because of different character encodings.
Use the UltraEdit editor that is installed
in the JKCC instead of Notepad. If you still have problems with UltraEdit,
use pico on DCS. Copy and paste your code into UltraEdit or pico,
save it and try running it again.
- What editor should I use
On a PC in the JKCC: UltraEdit. On DCS: pico or any other standard Unix editor
that is installed.
- How do I combine PHP and XML
All code outside <?php ... > needs to be XML (or HTML) tags.
All code inside <?php ... > needs to be echo statements or
other PHP commands.
For example, see the answer to exercise 5 from Week 3.
- My PHP page is completely empty when viewed through the browser
Check the permissions of the page, is it executable? If that's ok, do "View
page source".
- What if "View page source" shows the <?php ...> tags
This means that the webserver has not executed your PHP code.
- Are you using the correct URL in your browser? (A URL starting with "I:\" is
wrong.)
- Make sure that your PC doesn't save the PHP files with extension ".txt".
- If your script is producing SVG or XML output, make sure that there
isn't a blank line at the beginning of the script and the very first command is
creating the correct header.
If that's not the problem, see
the comment about invisible control characters above.
- I copied and pasted code from the exercise pages or the answers,
but it does not work
All of the code examples have been tested on DCS. Most likely your
problem is due to invisible control characters
or permissions (see the questions above). If you are absolutely sure that
that isn't the problem, send an email to me (u.priss) detailing the
problem.
- I get an error with a line number pointing to the end of the file
This means you forgot to close some string or expression. Check whether
all your opening brackets have closing brackets. Check your quotes (see
the question about nesting quotes below).
- I get an error, which doesn't look like a normal PHP error
This could be an XML error. Check whether the syntax of your XML code is correct.
Are all attributes quoted? Do you have closing tags?
- How do I nest quotes?
Long echo statements should be avoided because it can be difficult to
keep track of quotes. It is best to use single quotes for XML attributes
and double quotes for echo. In that manner you can include XML tags within
echo statements. You can include double quotes within double quotes if
you escape them by placing backslashes in front of the inner quotes.
- $_REQUEST[...] and $_POST[...] are not working
For some reason POST is disabled by C&IT for some students. Please, use
GET in your forms, if POST does not work.
- My own HTML pages have stopped working
For some reason C&IT seems to occasionally reset permissions. Go
to your home directory (the one above public_html) and type "chmod 711 .".
Questions about the coursework
- How do I display the data as an XML format
You don't necessarily
need to use PHP's builtin XML functions for this.
It may be easier to just use echo statements to produce the XML file. For example:
echo htmlentities("<quiz></quiz>");
prints the first and last tag. The htmlentities() command is necessary
so that the tags are literally displayed in the browser.
- Why can I not use SimpleXML
As far as I can see the "addChild" function for SimpleXML does not seem to
be implemented on DCS. Without that function, it doesn't seem possible
to use SimpleXML to create XML output which hasn't already be entered
in an XML format in the first place.
- What do you mean by "A file-display option"
A server-side script cannot save files on a user's computer. Thus
the only way to do this is to display the file content and to instruct
the user to save the file using the browser's "Save as" functionality.
- I have a quick question about the coursework
Send your question to me (u.priss) by email.
- I am completely stuck with the coursework
Talk to me during the practical about your questions. If we cannot
resolve your questions during the practical, we can arrange a time
to meet and discuss in more detail.
- I would like to use a MySQL account
I don't think MySQL is useful for the coursework. But if you
insist on using it, that's fine with me. Please, send an email
to me (u.priss) by the end of Week 5. I will then request an account
for you from C&IT.
Changes to the Coursework Description
Two small changes have been made to the coursework description
since it was first published. Both changes make the coursework easier.
- You are not required to use DOM or SAX, but you are required to write
briefly in your documentation whether or not you are using them.
- You are not required to read an XML file or to let users upload XML
files. You are only required to output the data in an XML format.
Questions about the exam
The format of the exam
- The exam will be short answer questions.
- You will not be asked to recite facts, but instead you will be
tested with respect to your understanding of the topics.
- If you are asked to write code in the exam, you can write it
either in PHP or Perl.
Revision
- What books to use for revision?
There should be a few relevant books in the library, but probably none
that covers completely and exactly the topics of this module.
I would probably recommend to go over the lecture notes and at least
some of the exercises again instead of reading lots of books.
What you can take with you to the exam
- The exam is an open-book exam. You may use any book and any
handwritten notes.
- You should take the following with you:
- the printouts that were handed out during class,
- any handwritten notes that you compiled during the semester,
- one book on PHP and one book on XML (especially useful are books with a good
index so that you can find things quickly).
- You may NOT use electronic devices (e.g. laptops, calculators,
mobile phones etc). If you require electronic devices because of
a disability or other reasons, you need to obtain advance permission.