CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Help with AddError code

Print topic Send  topic

Author Message
ckroon

Posts: 869
Posted: 04/05/2008, 9:11 AM

Hi All...

I pieced together some code after scoring the Message forum and came up with what I thought was good code. But I can't get it to go. T_object operator error keeps popping up.
I am trying to make it mandatory that a user enters a "reason" if the grade is C or below

Here is what I got. I'm close!...

$gradetable->grade->GetValue();  
if ($gradetable->grade->GetValue() >="C"&&(gradetable->reason->GetValue())=="")  
$gradetable->AddErrors("Must have a reason for grades lower than C.")

Thanks!

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
DonP
Posted: 04/05/2008, 11:43 AM

The problem is that "C" is not a value that can be more than or less
than but if you can change it to a numeric value, try something like this:

if (!$gradetable->reason->GetValue() && $gradetable->grade->GetValue()
<= 3) {
$gradetable->AddErrors("Must have a reason for grades lower than C.");
}

If you cannot change it to numeric, then you'll have to add each grade
letter to the conditional.

if (!$gradetable->reason->GetValue() && ($gradetable->grade->GetValue()
== "C" || $gradetable->grade->GetValue() == "D" ||
$gradetable->grade->GetValue() == "F")) {
$gradetable->AddErrors("Must have a reason for grades lower than C.");
}

Don (DonP)

ckroon wrote:
> Hi All...
>
> I pieced together some code after scoring the Message forum and came up with
> what I thought was good code. But I can't get it to go. T_object operator error
> keeps popping up.
> I am trying to make it mandatory that a user enters a "reason" if the grade is
> C or below
>
> Here is what I got. I'm close!...
>
>
$gradetable->grade->GetValue();  
> if ($gradetable->grade->GetValue()  
>> ="C"&&(gradetable->reason->GetValue())=="")  
> $gradetable->AddErrors("Must have a reason for grades lower than C.")
>
> Thanks!
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
ckroon

Posts: 869
Posted: 04/05/2008, 1:07 PM

Thanks Don!
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
ckroon

Posts: 869
Posted: 04/06/2008, 3:23 PM

Edited to this:

f (!$gradetable->reason->GetValue() && ($gradetable->grade->GetValue()
== "C" || $gradetable->grade->GetValue() == "D" ||
$gradetable->grade->GetValue() == "F")) {
$gradetable->errors->adderror("Must have a reason for grades lower than C.");
}

It works great!

Thanks DOn!

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message

Add new 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.

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.