Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
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."

You should 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.

Following up

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 articles
H050 - PHP - General
  [4314] PHP training - refreshed modern course, backed up by years of practical experience - (2014-11-16)
  [3966] Our examples work with any recent version of PHP - (2013-01-01)
  [3952] PHP revision ... by example. - (2012-12-15)
  [3530] A typical weekend?? - (2011-11-28)
  [3025] Learning to Program ... in PHP. Course examples. - (2010-11-01)
  [2663] Improve your PHP on a weekend away - (2010-03-05)
  [2559] Moving the product forward - ours, and MySQL, Perl, PHP and Python too - (2010-01-01)
  [2504] Learning to program in ... - (2009-11-15)
  [2430] Not just a PHP program - a good web application - (2009-09-29)
  [2400] Are you wanting to learn PHP? - (2009-09-08)
  [2227] Learning PHP, Ruby, Lua and Python - upcoming courses - (2009-06-11)
  [2222] A (biased?) comparison of PHP courses in the UK - (2009-06-07)
  [2097] PHP Course - for hobby / club / charity users. - (2009-03-22)
  [1722] PHP examples - source code and try it out too - (2008-07-26)
  [235] Preparation for a day's work - (2005-03-04)
  [116] The next generation of programmer - (2004-11-13)

H114 - Sourcing, installing and configuring PHP
  [4437] Adding a PHP build option, rotating an image based on camera data, and a new look at thumbnails in PHP - (2015-02-22)
  [4319] PHP - some quick fixes if scripts have issues, and how to use our support - (2014-11-19)
  [3955] Building up from a small PHP setup to an enterprise one - (2012-12-16)
  [3635] Parse error: parse error, unexpected T_STRING on brand new web site - why? - (2012-03-03)
  [3132] Virtual Hosting with Apache http server - an overall scheme, and avoiding common pitfalls - (2011-01-14)
  [2646] Compile but do not run PHP - syntax check only - (2010-02-22)
  [2433] Controlling, supressing, enabling PHP error messages - (2009-10-02)
  [2317] How to make a Risotto (PHP build style) - (2009-08-02)
  [1936] Quick Summary - PHP installation - (2008-12-12)
  [1768] What is built in to this httpd and PHP? - (2008-08-23)
  [1731] Apache httpd, MySQL, PHP - installation procedure - (2008-08-01)
  [1688] cannot restore segment prot after reloc message - PHP / httpd - (2008-06-26)
  [1667] Checking server performance for PHP generated pages - (2008-06-06)
  [934] Clustering, load balancing, mod_rewrite and mod_proxy - (2006-11-21)
  [481] PHP upgrade - traps to watch - (2005-10-31)
  [316] Development Environments - (2005-05-19)
  [192] Current MySQL and PHP paths and upgrades - (2005-01-28)

Back to
Freddies Wood and the K and A Canal
Previous and next
Horse's mouth home
Forward to
A healthy, local breakfast in Melksham
Some other Articles
Food and drink launch
Re-using our pictures
Melksham Hotel, B and B or business accommodation?
A healthy, local breakfast in Melksham
Your PHP code does not work? Here is where to start looking.
Freddies Wood and the K and A Canal
Bowerhill as a cycling community
And and Or illustrated by locks
Consultation in Melksham, on Melkshams future
Melksham Food and Drink Festival, 2010
4728 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95 at 50 posts per page

This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2017: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/2589_You ... king-.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat