CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Function with addERROR [RESOLVED]

Print topic Send  topic

Author Message
acedrummond


Posts: 89
Posted: 05/31/2021, 5:05 PM Quote message

I built a function and within the function want to place errors via add error i.e.

My code:

function check_phone_fields($which, $ph_num, $ph_type, $ph_text, $ph_carrier)
{
$Container = & CCGetParentContainer($sender);
//No phone number specifed
if ($ph_num == '')
{
if ($ph_type <> 'N')
{
$Container->Errors->addError("No $which Number - Type must be NOT USED used");
}
if ($ph_text <> 'N')
{
$Container->Errors->addError("No $which Number - $which Text must be NOT USED used");
}
if ($ph_carrier <> '')
{
$Container->Errors->addError("No $which Number - $which Carrier must not be NOT USED used");
}
}

// Phone Number is Specified
if ($ph_num <> '')
{
if ($ph_type == 'N')
{
$Container->Errors->addError("$which is present - Phone Type must be SPECIFIED");
}
if ($ph_type == 'C' and $ph_carrier == '')
{
$Container->Errors->addError("$which is Cell - Carrier must be SPECIFIED");
}
if ($ph_type == 'C' and $ph_text == '')
{
$Container->Errors->addError("$which is Cell - Text Option must be SPECIFIED");
}
if ($ph_type == 'L' and $ph_text <> 'N')
{
$Container->Errors->addError("$which is Land Line - Text must be NOT USED");
}
if ($ph_type == 'L' and $ph_carrier <> '')
{
$Container->Errors->addError("$which is Land Line - Carrier must NOT be SPECIFIED");
}
}
return;
}
I get error when I try to execute

Fatal error: Call to a member function addError() on null in C:\wamp64\www\sdc\member_profile_events.php on line 192

This same code when I put it within an event and without it coded in a function works perfectly.

I have to do this function multiple times for different fields in my application and would prefer to re use the code vs. duplicating it.

What am I missing?
_________________
Ace Drummond
View profile  Send private message
acedrummond


Posts: 89
Posted: 06/10/2021, 10:03 AM Quote message

Resolved by passing errors back to the calling code and issuing adderror there.
_________________
Ace Drummond
View profile  Send private message

Add new topic Reply to topic Subscribe to topic   


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

MS Access to Web

Convert MS Access to Web.
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.