开发者

Kohana Database query in a view file

I am using gallery3 which is written in kohana framework. I want to execute database query in a theme view file. the page output stops when it is encountering the query.

Link- http://techmax.co.in/movie/gallery3/index.php/Ye-Maaya-Chesave-Movie

$curr_url = url::current();
    $exp= explode('/',$curr_url);
    if (preg_match("/\bMovie\b/i","$curr_url")){
        $query = mysql_q开发者_C百科uery ( "SELECT name,id FROM movies WHERE gallery LIKE '%$exp[0]%' ");
    $row = mysql_fetch_array($query);  ?>
    <font size="+2"><a href="http://techmax.co.in/movie/movies.php?mov_no=<? echo $row[1]; ?>"><? echo $row[0] ?> Movie Page</a></font>  <?  }
    else if(preg_match("/\bStar\b/i","$curr_url")){
        $query = mysql_query ( "SELECT name,id FROM stars WHERE gallery LIKE '%$exp[0]%' ");
    $row = mysql_fetch_array($query);  ?>
    <font size="+2"><a href="http://techmax.co.in/movie/stars.php?star_no=<? echo $row[1]; ?>"><? echo $row[0] ?> Star Page</a></font> <? }
        ?>

This code is in the page gallery3/themes/wind/views/page.html.php

If the query executes correctly there should be some text behind the movie page link at top right corner


Try changing all your <? tags to <?php tags instead. Many servers are configured to disallow the short opening tags to avoid confusion with <?xml declarations.

If your page works on your test server but not on live, there is a good chance this is at least one of the problems.

Also, verify that you MySQL actually connected successfully...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜