Sparse - Errors
There are three kinds of errors printed out in Sparse. Not only can you
configure what they look like, you can also configure where they go!
You can do this via three separate tags.
The message is the big message like "Updated rows!", "There was an
error in inserting one or more rows.", etc. You can place it by using
tag. Wherever that tag goes is where the message goes. If there is no
sqlmessage tag, by default it will be placed at the
very top of the page inside <H2> tags.
Hopefully you'll never see this one; it happens when there's an actual
SQL error in inserting/updating data. This might be because you
misspelled the name of a field, or the user tried to insert a string
into an integer field, etc. There's always the possibility that Sparse
messed up, of course, so if you see an error you shouldn't, please
You can place this error using the
sqlrowerror tag. By
default it will not appear at all
(instead, the Message will give a
general "failed to insert one or more rows") so look sharp!
The most useful of the errors is what happens when a field is given the
wrong value (e.g. left blank even though the
attribute is set, or the
attribute evaluated to false). By default the message will be inserted
just before the offending
tag, followed by a <BR />.
Because every field has an associated message,
sqlerror is the only tag which takes another
of the field it's associated with. This name must be the returned name
of the field; if you used an alias and called your field "e.name AS
must be "ename".
Styling Your Errors
By default every error has its own CSS style. You can
change the class or style to whatever you want by setting the class or style
attributes of the tag.
In addition, every error tag has two more attributes:
The point of these is simple: generally, if the error does appear,
you'll want it to be preceded or followed by some code (such as a
<tr></tr>), but not if it doesn't appear. These attributes
allow you to define HTML code which should be printed only if the error is printed. Note
that the following example is not
proper XHTML markup, but by the time it's printed it will be. 8-)
<sqlerror name="employees.name" startMarkup="<tr><td
colspan='5'>" endMarkup="</td></tr>" />
Previous: Working With
Data | Errors | Linking to Templates