-2

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

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

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

这是我在打开 HTML 标记之前的 PHP 代码(在我希望添加星级脚本的页面中):

<?
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++;
    }
}
?>

这是显示<div>包含 start 的评级的代码:

<?php $rr->showStars("anotherGreatArticle"); ?> 

当我将此添加到我的页面时,它不会在页面上显示任何内容,并且页面仅加载到一半。

我将如何整理并使其发挥作用?

4

2 回答 2

2

存在语法错误:

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

应该

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

你忘了关require_once("ratings.php")

于 2013-06-02T18:10:25.283 回答
2

你在 require_once() 之后伪造了一个右括号。

如果您使用带有语法和错误突出显示的编辑器/IDE,则不会发生这种情况。任何体面的编辑器都应该立即在错误代码下划线。具有这种能力的免费编辑器是 Notepad++、Netbeans、Eclipse(按学习曲线从易到难排序——可以说。)

于 2013-06-02T18:17:10.120 回答