Can't seem to echo a function result?

Hi,

I have been trying to echo a function result, but I’m a little lost here.
If I don’t call the function it works it prints out the html code (without the function part), but if I call the function, I get a blank screen.

any help?

[php] <?php

function GenerateMbRef($order_id, $order_value)
{
// IMPORTANTE: Coloque aqui o seu codigo de entidade e sub-entidade correctamente
$ent_id = “11202”;
$subent_id = “189”;
$order_id =“0000[INVOICENO]”;
$order_value = trim("[ORDERAMOUNT]" , ‘€’); // only delete € at start or end of the string

   //     Apenas são considerados os 4 caracteres mais à direita do order_id
   $order_id = substr($order_id, (strlen($order_id) - 4), strlen($order_id));

 if ($order_value < 1){
             echo "Lamentamos mas é impossível gerar uma referência MB para valores inferiores a 1 Euro";
             return;
       }
       if ($order_value >= 1000000){
             echo "<b>AVISO:</b> Pagamento fraccionado por exceder o valor limite para pagamentos no sistema Multibanco<br>";
       }
       while ($order_value >= 1000000){
             GenerateMbRef($order_id++, 999999.99);
             $order_value -= 999999.99;
       }
                          
       
    //cálculo dos check digits
       
       $chk_str = sprintf('%05u%03u%04u%08u',$ent_id, $subent_id, $order_id, round($order_value*100));
       
       $chk_array = array(3, 30, 9, 90, 27, 76, 81, 34, 49, 5, 50, 15, 53, 45, 62,38, 89, 17, 73, 51);
       
       for ($i = 0; $i < 20; $i++)
       {
             $chk_int = substr($chk_str, 19-$i, 1);
             $chk_val += ($chk_int%10)*$chk_array[$i];
       }
       
       $chk_val %= 97;
       
       $chk_digits = sprintf('%02u', 98-$chk_val);
       
       $teste .= "<pre>";
       $ref1= $subent_id." ".substr($chk_str, 8, 3)." ".substr($chk_str, 11, 1).$chk_digits;
return $ref1;
}  

$ent_id = “11202”;
$subent_id = “189”;
$invoice_id ="[INVOICENO]";
$order_amount = trim("[ORDERAMOUNT]" , ‘€’); // only delete € at start or end of the string

?>

 <table cellpadding="3" width="300px" cellspacing="0" style="margin-top: 10px;border: 1px solid #45829F; background-color: #FFFFFF;">
<tr>
    <td style="font-size: x-small; border-bottom: 1px solid #45829F; background-color: #45829F; color: White" colspan="3"><center>Pagamento por Multibanco ou Homebanking</center></td>
</tr>
<tr>
    <td rowspan="3"><center><img src="/images/icons/MB.gif" alt="" width="52" height="60"/></center></td>
    <td style="font-size: x-small; font-weight:bold; text-align:left">Entidade:</td>
    <td style="font-size: x-small; text-align:left"><?php echo $ent_id; ?></td>
</tr>
<tr>
    <td style="font-size: x-small; font-weight:bold; text-align:left">Referência:</td>
    <td style="font-size: x-small; text-align:left"><?php /* echo GenerateMbRef($invoice_id, $order_amount) */ ?></td>
</tr>
<tr>
    <td style="font-size: x-small; font-weight:bold; text-align:left">Valor:</td>
    <td style="font-size: x-small; text-align:left"><?php echo "[ORDERAMOUNT]" ?></td>
</tr>
<tr>
    <td style="font-size: xx-small;border-top: 1px solid #45829F; background-color: #45829F; color: White" colspan="3">O talão emitido pela caixa automática faz prova de pagamento. Conserve-o.</td>
</tr>
[/php]

Turn error reporting on and see what the issue is. It also looks like you are having that function do too many things.

Sponsor our Newsletter | Privacy Policy | Terms of Service