首页 > 解决方案 > Smarty 未定义索引变量

问题描述

我是 smarty 的新手,并试图在从 php 获取的 tpl 文件中输出一些结果。在我的account.php文件中,我放了下面的代码

<?php
  include SMARTYLOADER;
  $ad2 = $db->fetchRow("SELECT * FROM ip_ptc");
  $smarty->assign("ad2", $ad2);
  $smarty->display("account.tpl");
  $db->close();
  exit();
 ?>

在我的account.tpl文件中我写了下面的代码来获取结果

{$ad2.country}

但它显示了一个未定义的索引变量ad2我在做什么错

标签: phpmysqlsmarty

解决方案


推荐阅读