有人可以帮助我,因为我是 PHP 新手。
我正在使用 smarty 模板引擎,我想做的是在我的网站上,每部电影都有自己的类别,我正在尝试使用此功能在电影下方显示类别。
/* returns a list of categories (including ids and details) for the given movie */
public function getMovieCategoryDetails($movieid,$lang=null){
$movieid = mysql_real_escape_string($movieid);
$e = mysql_query("SELECT * FROM movie_tags WHERE id IN (SELECT tag_id FROM movie_tags_join WHERE movie_id=$movieid)") or die(mysql_error());
$tags = array();
if (mysql_num_rows($e)){
while($s = mysql_fetch_array($e)){
$s['tag'] = json_decode($s['tag'],true);
if ($lang){
$s['tag'] = $s['tag'][$lang];
}
$tags[$s['id']] = $s;
}
}
return $tags;
}
然后 this 调用该函数。
$tags = $movie->getMovieCategoryDetails($movieid,$language);
if (count($tags)){
$smarty->assign("tags",$tags);
}
然后这个来显示它。
{if $movie_tags}
<tr>
<td width="70"><strong>Tags:</strong></td>
<td style="width:387px; float:left;">
<span class="movie_info">
{foreach from=$movie_tags key=tag_id item=tag name=tags}
{$tags}
{/foreach}
</span>
</td>
</tr>
{/if}
但是得到这个错误。
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
在 PHP_ERROR_LOG 我得到了这个错误。
[11-Oct-2013 11:18:16 Europe/Berlin] PHP Notice: Undefined variable: movieid in C:\xampp\htdocs\home.php on line 69
谁能指出我解决此错误的方向。
谢谢