PHP Troubleshooting
Questions about the coursework
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
- For the logo creation application: is it ok if I just create a
form field for each SVG feature?
That is not a good idea because that would mean you are creating an
SVG editor. Users who don't know SVG might have difficulty
understanding what values to fill into the form. Your application
should be usable by anybody on the web. It should be easy and quick to
fill in the form.
- For the network visualiser: how do I generate SVG output?
Graphviz can generate SVG. You just need to change it from "gif" to
"svg". The content-type should be "svg+xml".
- Can I use ASP or .NET for the coursework?
This module is intended to be UNIX-oriented. We have two other
modules ("SET09104 Application Development" and "SET10104 XML Web
Services") which cover similar topics from a .NET side.
Our intention is to give you both Unix and PC experience while you
are studying with us.
Therefore, although you don't need to run your coursework
on Unix hardware because you can install WAMP on your PC, you should
use a configuration that could be installed on a Unix server with
a normal setting (i.e. Apache, which is MySQL, Perl, PHP or Python enabled).