Your PHP code does not work? Here is where to start looking.
If people take the trouble to write to me and ask for help when one of the examples on our web site isn't working for them, the least I can do is to provide them with a few pointers.
But it's really hard for me to provide help when the questioner doesn't tell me the symptoms of what's wrong. Would you go to the doctor and ask him for medical help, and leave him to guess what the problem was ... neglecting to tell him that your knee had hurt ever since you fell on it? That's what you're doing if you say just "The code doesn't work. But demo working. Please provide correct code."
start by telling me the symptoms of HOW the code fails for you ... then I can look at your knee and not try to diagnose a sore throat .. however, here are some of my top tips for newcomers to debugging our PHP examples (and the term "newcomers" applies to people who've not been coding long enough to know I need symptoms!):
Quick Checks if our tested PHP code fails to work on your system
a) Many of our examples use $_REQUEST in the code which was only available from PHP version 4.1; if you have a very old version of PHP, it may not be supported. We use this $_REQUEST because it (along with $_GET and $_POST, also added at 4.1) is the only way you can read in data from forms in a current default configuration
b) Some of our examples uses the <?= short tag ... short tags are enabled by default on install, but on a few systems they may be turned off, and if that's the case on your installation you'll need to change the code if they're not permitted
c) One of the very common cut and paste errors with PHP is that people grab an extra space before the first character - the < - of the <?php at the start of the code, and if you're using cookies or otherwise changing the header, just this extra white space can cause the script to fail.
d) You need to have PHP installed on your web server, and configured to process PHP for the particular file extension that you have chosen to save the file as. The extension of the file on our web site was probably ".php" which is the commonly used one, but your server may need to be set up to use that extension, or you might have called the file .html or something like that, in which case it's unlikely to work without a configuration or name change
e) If you have cut and pasted the example through MicroSoft Word or another editor that has produced a file which is NOT plain text and/or include text markups of its own, PHP won't be able to understand it and you need to use a different editor / save as plain text
f) Check that the file isn't called units.php.txt or someting like that - some editors are very good at adding an extra extension which, again, will render the script unusable.
g) If your PHP is set to pedantically check for warnings in the PHP code, you may find that our examples will generate warnings - rather than obscure the code with lots of checks, we keep the demos straightforward. It is possible that your PHP is configured to fail even if it gets a warning, and that's what's causing you problems.
You may have guessed that I'm writing this in response to a question I have just received via a published comment on our web page, which came to me for review. It's much better to use our ask the tutor page
at http://www.wellho.net/net/alaska.php - but real "newbies" do need all the help they can get sometimes, and I'll pick up drowning cries for help from reviews too.
I hope the answer above (in a slighly more specific form) has helped my correspondent. I followed up with the following text:
Please have a look through the above. And (so that I can complete the 'case' , comment back on the review page and add comments to the program if you've been caught by a trap I should warn people about), please let me know the symptoms that were being shown and the solution. If the above doesn't lead you to a solution, you're welcome to follow up - preferable via our forum, or if you're in our area to pop by and I'll have a look at it with you. If you're thinking "I don't get what you're saying there" with any of the suggested solutions that I've come up with, can I suggest that you would do well to come on one of our courses so that we can sort out not only your immediate issue, but all those other issues which will inevitably crop up as you get deeper into PHP.
On past form, it's more likely than not that I won't even hear back, but a significant minority do get back in touch. And I have long learned that an unacknowledged email doesn't always mean a problem not solved; cases come to light where I think "my goodness - I went to the trouble to help and (s)he was so rude as to not acknowledge" but
(s)he has recommened us on to others, or indeed got in touch at a later date with an apology for the lack of an earlier response ... and perhaps with a further question (!) or even something more substantial that will help us pay salaries!
Those PHP courses that I mentioned - see [here]
for the four or five different courses we offer. If you're having issues with your PHP, and you can't say "yes - I should check that and I know how to" to my items a) through g) then chances are you'll gain a lot from a course! (written 2010-01-18)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesH050 - PHP - General 
PHP training - refreshed modern course, backed up by years of practical experience - (2014-11-16) 
Our examples work with any recent version of PHP - (2013-01-01) 
PHP revision ... by example. - (2012-12-15) 
A typical weekend?? - (2011-11-28) 
Learning to Program ... in PHP. Course examples. - (2010-11-01) 
Improve your PHP on a weekend away - (2010-03-05) 
Moving the product forward - ours, and MySQL, Perl, PHP and Python too - (2010-01-01) 
Learning to program in ... - (2009-11-15) 
Not just a PHP program - a good web application - (2009-09-29) 
Are you wanting to learn PHP? - (2009-09-08) 
Learning PHP, Ruby, Lua and Python - upcoming courses - (2009-06-11) 
A (biased?) comparison of PHP courses in the UK - (2009-06-07) 
PHP Course - for hobby / club / charity users. - (2009-03-22) 
PHP examples - source code and try it out too - (2008-07-26) 
Preparation for a day's work - (2005-03-04) 
The next generation of programmer - (2004-11-13)H114 - Sourcing, installing and configuring PHP 
Adding a PHP build option, rotating an image based on camera data, and a new look at thumbnails in PHP - (2015-02-22) 
PHP - some quick fixes if scripts have issues, and how to use our support - (2014-11-19) 
Building up from a small PHP setup to an enterprise one - (2012-12-16) 
Parse error: parse error, unexpected T_STRING on brand new web site - why? - (2012-03-03) 
Virtual Hosting with Apache http server - an overall scheme, and avoiding common pitfalls - (2011-01-14) 
Compile but do not run PHP - syntax check only - (2010-02-22) 
Controlling, supressing, enabling PHP error messages - (2009-10-02) 
How to make a Risotto (PHP build style) - (2009-08-02) 
Quick Summary - PHP installation - (2008-12-12) 
What is built in to this httpd and PHP? - (2008-08-23) 
Apache httpd, MySQL, PHP - installation procedure - (2008-08-01) 
cannot restore segment prot after reloc message - PHP / httpd - (2008-06-26) 
Checking server performance for PHP generated pages - (2008-06-06) 
Clustering, load balancing, mod_rewrite and mod_proxy - (2006-11-21) 
PHP upgrade - traps to watch - (2005-10-31) 
Development Environments - (2005-05-19) 
Current MySQL and PHP paths and upgrades - (2005-01-28)
Some other Articles
Food and drink launchRe-using our picturesMelksham Hotel, B and B or business accommodation?A healthy, local breakfast in MelkshamYour PHP code does not work? Here is where to start looking.Freddies Wood and the K and A CanalBowerhill as a cycling communityAnd and Or illustrated by locksConsultation in Melksham, on Melkshams futureMelksham Food and Drink Festival, 2010