如何实现这段代码


How to implement this code?

我不是PHP专家。我想实现一个星级评级脚本。因此,我想在页面的开头为评级实现:

<?php require_once("ratings.php"; $rr = new RabidRatings(); ?>

但是,这会给我一个服务器错误。

这是我的PHP代码之前的打开HTML标签(在我希望实现星级脚本的页面):

<?
include "admin/configuration/config.php";
include "admin/configuration/main_class.php";
function en_string($str)
{
    return strtolower(str_replace(" ", "_", trim($str)));
}
function de_string($str)
{
    return str_replace("_", " ", trim($str));
}
;
$id = en_string($_GET['id']);
$id2 = en_string($_GET['id2']);
;
$path = "../";
if($id2)
{
    $sql = "SELECT * FROM fh_categories AS a JOIN fh_subcategories AS b ON a.fh_Cid=b.fh_Cid JOIN fh_software AS c ON b.fh_SCid=c.fh_SCid JOIN fh_version AS d ON d.fh_Sid=c.fh_Sid WHERE d.fh_Sid='$id' and d.fh_Vid='$id2' ";
    $path = "../../";
}
else
{
    $sql = "SELECT * FROM fh_categories AS a JOIN fh_subcategories AS b ON a.fh_Cid=b.fh_Cid JOIN fh_software AS c ON b.fh_SCid=c.fh_SCid JOIN fh_version AS d ON d.fh_Sid=c.fh_Sid WHERE d.fh_Vfront=1 and d.fh_Sid='$id'";
}
$query1 = mysql_query($sql);
$rec = mysql_fetch_array($query1);
$cid = $rec['fh_Cid'];
$scid = $rec['fh_SCid'];
$sid = $rec['fh_Sid'];
$description = $rec['fh_Sdescription'];
$technical = $rec['fh_Vtechnical'];
$changelog = $rec['fh_VchangeLog'];
$caption = $rec['fh_Sid'];
$company = $rec['fh_Scompany'];
$homepage = $rec['fh_Shomepage'];
$icon = $rec['fh_Sicon'];
$version = $rec['fh_Vcaption'];
$shot = $rec['fh_Vscreenshot'];
$size = $rec['fh_Vsize'];
$license = $rec['fh_Vlicense'];
$extension = $rec['fh_Vextension'];
$platform = $rec['fh_Vplatform'];
$did = $rec['fh_Did'];
$date = strftime("%d %b %Y", $rec['fh_Vdate']);
$language = "English";
$j = 1;
for($i = 0; $i < (strlen($shot)); $i++)
{
    if($shot[$i] != ';')
    {
        $screenshot[$j] .=$shot[$i];
    }
    else
    {
        $j++;
    }
}
?>

这是显示包含start:

的评级<div>的代码
<?php $rr->showStars("anotherGreatArticle"); ?> 

当我把这个添加到我的页面时,它不会在页面上显示任何东西,并且页面只加载了一半。

我该如何解决问题并使其发挥作用?

语法错误:

<?php require_once("ratings.php"; $rr = new RabidRatings(); ?>
应该

<?php require_once("ratings.php"); $rr = new RabidRatings(); ?>
//                              ^   forgot to close this

忘记关闭require_once("ratings.php")

您在require_once()之后忘记了一个右括号。

如果您使用带有语法和错误高亮显示的编辑器/IDE,则不会发生这种情况。任何优秀的编辑都应该立即在错误的代码下面加下划线。具有这种功能的免费编辑器有notepad++, Netbeans, Eclipse(根据学习曲线从容易到难排序-有争议)