Jump to content

[SOLVED] Try Catch


acp26b

Recommended Posts

Dang, any suggestions for this?

[code]
try {
    $db_percent = mysql_result($balancefeeresult,0,"percentcharge");
    $db_amount = mysql_result($balancefeeresult,0,"amount");
}catch (Exception $e) {
$exception = "true";
}
if($exception != "true"){
$db_percent = ($db_percent * .01);
$charge = ($db_percent * $db_amount);
}else{
$charge = NULL;
}[/code]

What i want to do, is if no amount comes out of db then set charge to null
Link to comment
https://forums.phpfreaks.com/topic/35916-solved-try-catch/#findComment-170314
Share on other sites

got it!
[code]
$balancefeenumber = mysql_numrows($balancefeeresult);
if(!$balancefeenumber){
$charge = 0;
}else{
$db_percent = mysql_result($balancefeeresult,0,"percentcharge");
$db_amount = mysql_result($balancefeeresult,0,"amount");
$db_percent = ($db_percent * .01);
$charge = ($db_percent * $db_amount);
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/35916-solved-try-catch/#findComment-170327
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.