2013-06-02 126 views
-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>启动代码:

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

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

我会如何整理和完成工作?

+0

请缩进您的代码。 http://www.youtube.com/watch?v=EsF2Sb3pf6w – mzedeler

+1

'require_once'需要一个右括号。 –

回答

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")

2

您require_once后forgt一个右括号()。

如果使用带语法和错误突出显示的编辑器/ IDE,则不会发生这种情况。任何体面的编辑器都应该立即强调错误的代码。具有这种功能的免费编辑器是Notepad ++,Netbeans,Eclipse(可以从简单到艰苦的学习曲线进行排序 - 可以说)。