Error messages
Since version 1.2 on error messages are divided into three groups:
- syntax errors
- file errors (read/write or filesystem)
- database structure errors
Please notice that these error messages are not meant to substitute PHP own error messages, but rather come as a useful complement. Be sure to set your PHP errolevel to E_ALL during development (read in PHP manual how to do it).
Syntax errors
Sample error message:
Syntax error called from ptb_create in file <path to file>/index.php on line no. 132: ptb_create('novels.csv', 'L'); message: this function needs at least 3 arguments!
These errors occur when you improperly call a function, eg. give too little arguments, use forbidden char or omit required one, eg.
These samples correctly should look like these:
These errors are always fatal, which means that pjjTextBase will always die() on them, no matter if PTB_SHOW_ERRORS is set to true or false.
How to avoid: consult your documentation! ;-)
File errors (read/write or filesystem)
Sample error message:
File error (read/write or filesystem) called from ptb_connect in file <path to file>/index.php on line no. 132: $novels = ptb_connect('novelz.csv', 'L'); message: file <path to file>/novelz.csv does not exist!
These errors occur when pjjTextBase can't find a file, can't open a file or can't write to a file.
These errors do not stop your script from executing. You are thus advised to use conditional structures to catch the error and use appropriate means, eg.
How to avoid: in most cases file errors (especially when a file can't be read or opened) are due to too restrictive file or directory permissions–make sure that your script is allowed to open or write to a file and use chmod if necessary.
Database structure errors
Sample error message:
Database structure error called from ptb_map in file <path to file>/index.php on line no. 132: $test = ptb_map($novels.csv, "'id' == 3", 'country'); message: field country does not exist in this database
These errors occur when you make reference to a field in your database that does not exist, eg.
or when you want to change field's name to the one which does exist:
Another (and last) case is when you use variable supposed to be an array but, in fact, isn't.
These errors do not stop your script from executing.
How to avoid: in most cases database structure errors are due to programmer's mistake (eg. misspelled field name).
This version (1.2) comes with no error stack nor error logging; perhaps they will be available in future releases.