CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 MySQL error trapping with PHP

Print topic Send  topic

Author Message
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

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.