0

私はphpで次の関数を作成しました。smarty ファイルから呼び出したいのですが、smarty からエラーが発生し続けます。私は何を間違っていますか?

<?php
function getCommission($inputid)
{
    $database="xxxxxxxxxxxxxx";
    mysql_connect (xxxxxxxxxxxxxxxxx);
    @mysql_select_db($database) or die( "Unable to select database");

 $data = mysql_query("SELECT * FROM hb_aff WHERE id = $inputid") 
 or die(mysql_error()); 
 while($info = mysql_fetch_array( $data )) 
 { 
 return $info['total_commissions'];
 } 
}
 ?>

tpl コードの一部は次のとおりです。

     {include file="getCommission"} 
<tr>
    <td >{$lang.convrate}</td>
    <td >{$affiliate.conversion} %</td>
    <td >{$lang.commissions}</td>
    <td ><input size="3" value="{getCommission($affiliate.id}" name="total_commissions"/></td>
                            </tr>            
4

2 に答える 2

0

最後の称賛の前にここで括弧を逃したと思います:

"{getCommission($affiliate.id}"
于 2013-08-12T13:11:48.697 に答える
0

を使用するのではなく、まず関数を Smartyに登録する必要があります{include}

<?php
$smarty->registerPlugin("function","getCommission", "getCommission");
于 2013-08-12T13:12:28.567 に答える