Ville
|
| Posted: 10/11/2002, 4:12 PM |
|
Hello everybody,
I'm working on a simple "news & specials" application (for customer to be able to update their website news/specials using an online tool) in CodeCharge Studio, and I'm having problems with MySQL error trapping.
Where should I enter the error trapping code? I have tried adding the following custom code:
if (mysql_error() <> 0) {
print("error occurred: " . mysql_errno() . "<BR>");
print("error occurred: " . mysql_error());
}
.. in the form's properties ('After Execute Insert' and 'After Insert') as well as in the properties of the field ('On Validate') that causes the error when a duplicate entry is added (the field is set as 'unique' in the database).
But to no avail. When I try adding a duplicate entry the following error is displayed:
---
Database error: Invalid SQL: INSERT INTO Locals (username, password) VALUES ('code', 'test')
MySQL Error: 1062 (Duplicate entry 'code' for key 4)
Session halted.
---
It seems that my custom code is never reached because the trapping code is correctly evaluated when insertion occurs (when a non-existing data is entered). So I'm wondering if I'm entering the custom code in the wrong place? The form works otherwise as expected; adds/views/deletes records ok as long as invalid data is not entered.
Any advise, anyone?
Thanks!
// Ville
|
|
|
 |
Ville
|
| Posted: 10/11/2002, 4:30 PM |
|
As always, posting on a forum helps - one generally finds the resolution immediately thereafter ;).
I hadn't made the field "unique" in field's properties in CodeCharge Studio. Now it checks for duplicates.
// Ville
|
|
|
 |
|