Appendix A. Troubleshooting

At some point in your career, you might experience problems with your code; no matter how diligently you try to work, errors do creep in. So common are errors (most often called bugs), in fact, that any big corporation nowadays has to implement comprehensive testing and debugging plans for months on end before it can consider new software to be fairly stable. Even then, as you have probably experienced, there are problems that slip under the radar and require patches or updates.

Since bugs are a part of life, it is better to learn how to deal with them properly than to hope to avoid them completely. This appendix will provide a few neat methods, as well as reiterate the best process for dealing with bugs. Remember, though, that if worst comes to absolute worst, and your site is beyond repair for one reason or another, then simply erase and fall back to your latest backup.

Types of Errors

Ensuring that your application is ‘bug’ or error free is a critical part of developing and building any software—and e-commerce websites are no different. There are different ways and means of isolating faults and correcting them, but before we look at those it is important to quickly acknowledge the different types of error that can make their unwelcome presence felt. Different types of errors also show in different ways and some are quite subtle and not easy to spot:

  • Syntax error: These will prevent PHP from actually running your code, but on the plus side should be relatively easy to locate because of this. Of course, once your site is being used by the general public, you dont really want the internal errors in your system being reported to the screen, because this can often allow malicious users to glean information about your system.
  • Run-time error: These are slightly worse than syntax errors because they are not quite as obvious, or easy to pin down. There are different ways in which a run-time error can occur, and many of these can only be caught by thorough testing on your site. For example, if you change file paths without the corresponding configuration changes, you end up with broken links, lost files, or disrupted database connections. While these errors wont show up when the PHP script is parsed, they will show up when it is executed.
  • Logic error: These are quite sneaky in that they wont really show up at all. It is incumbent on you to decide whether your site is performing as it should. For example, accidentally typing a plus (+) sign instead of a minus (-) wont show up as either a run‑time error or a syntax error, but will obviously affect the result of a calculation, which could have disastrous effects if it is part of your invoice calculator.

It is important that you are able to decide for yourself what type of error has occurred. Often, it takes a bit of experience to realize what an error message usually means because PHP can’t always isolate the exact place an error has occurred. If you have already found yourself suffering from seemingly cryptic error messages, then read on to the Debugging Code Yourself section for help on a variety of issues.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.20.68