Firefox 3

Error messages

Since version 1.2 on error messages are divided into three groups:

  1. syntax errors
  2. file errors (read/write or filesystem)
  3. 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.

ptb_create('novels.csv', 'L'); ptb_update('novels.csv', 'L', "'id' > 10", "'year' == '1970'");

These samples correctly should look like these:

ptb_create('novels.csv', 'L', 'id|title|%aka|@protagonist|year'); ptb_update('books.csv', 'L', "'id' > 10", "'year' = '1970'");

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.

if (!ptb_add('novels.csv', 'L', '11|Hercule Poirot\'s Christmas|3,4|1|1938');)) { echo 'Server error, can\'t add record to the database.'; echo 'Please contact webmaster at webmaster@mydomain.net'; }

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.

$database = ptb_connect('novels.csv', 'L', false, 'country');

or when you want to change field's name to the one which does exist:

ptb_changeFieldname('novels.csv', 'L', 'id', 'year');

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.