[Textpattern] - css_rating_bar zeigt MySQL error

G

Gast170816

Hallo,

in der Höffnung, dass sich hier der Ein oder Andere sehr gut mit Textpattern auskennt, eine Frage zu dem Plugin "css_rating_bar":

Mit diesem Plugin kann man ein tolles Sterne-Rating für Blogpost einbauen, allerdings will es bei mir auch nach dem zweiten Installationsversuch nicht richtig klappen. Außerdem verwende ich eine Datenbank mit Tabellenpräfixen, weil ich unbedingt mehrere Textpattern-Installationen in einer Datenbank betreiben möchte.

Also nach Installation des css_rating_bar-Plugin kommt folgender Error auf der Webseite:

Code:
Tag error: <txp:css_rating_bar units=“5” /> -> Warning: mysql_num_rows() expects parameter 1 to be resource, array given on line 300


Was ist das für ein Fehler und wie bekomme ich ihn weg?
Außerdem scheint auch mit der Rating-Fuktion selbst etwas nicht zu stimmen, das Tag <txp:css_rating_bar units=“5” /> für die Rating-Bar hab ich im allgemeinen Template eingefügt, das die Blogposts anzeigt...so müsste also für jeden Blogpost ein individuelles Rating möglich sein. Mir wird aber überall das selbe Ratingergebniss angezeigt.

PS: Wenn ich die Seite mit den Blogposts und Ratings nochmal neu lade wird es noch schlimmer, es kommt zusätzlich noch folgende Fehlermeldung hinzu
Code:
Tag error: <txp:css_rating_bar units=“5” /> -> Textpattern Warning: Duplicate entry ‘1’ for key ‘PRIMARY’
insert into sw_txp_ratings set id=‘1’,total_votes=1, total_value=‘7’, used_ips=’‘ on line 85

Textpattern ist nicht so bekannt, als dass man an jeder Ecke die Lösung für Probleme findet, ich hoffe aber hier weiß evtl. doch jemand bescheid, was hier falsch gelaufen sein könnte.

Hier auch nochmal die php-Datei, die sich hinter dem Plugin verbirgt:
PHP:
// ----------------------------------------------------

function css_rating_bar($atts="") {
global $thisarticle;
$tableName="txp_ratings";

		extract(lAtts(array(
			"id"=>$thisarticle['thisid'],
			"units"=>"10",
			"unitwidth"=>"30",
			"firstvote"=>"7"
		),$atts));

//set some variables
$ip = $_SERVER['REMOTE_ADDR'];

$numbers=safe_row("total_votes, total_value, used_ips", $tableName, "id = $id");
if(numRows($numbers)==0){
	safe_insert($tableName, "id='$id',total_votes=1, total_value='$firstvote', used_ips=''");
	$numbers=safe_row("total_votes, total_value, used_ips", $tableName, "id = $id");
}
extract($numbers);

$count=$total_votes; //how many votes total
$current_rating=$total_value; //total number of rating added together and stored
$tense=($count==1) ? "vote" : "votes"; //plural form votes/vote

// determine whether the user has voted, so we know how to draw the ul/li
$voted = getCount("$tableName", "used_ips LIKE '%$ip%' AND id=$id");


// now draw the rating bar


$output="
<div class=\"ratingblock\">

<div id=\"unit_long$id\">
<ul id=\"unit_ul$id\" class=\"unit-rating\" style=\"width:".($unitwidth*$units)."px;\">
		<li class=\"current-rating\" style=\"width:".@number_format($current_rating/$count,2)*$unitwidth."px;\">Currently ".@number_format($current_rating/$count,2)."/$units</li>
";

	for ($ncount = 1; $ncount <= $units; $ncount++) { // loop from 1 to the number of units
		if(!$voted) { // if the user hasn't yet voted, draw the voting stars
		$output.="<li><a href=\"javascript:sndReq('".base64_encode("$ncount:$id:$ip:$units:$unitwidth")."','$id')\" title=\"$ncount out of $units\" class=\"r$ncount-unit rater\">$ncount</a></li>
		";
	 }
  }
	$ncount=0; // resets the count
		$output.="	</ul>
		<p";
		if($voted){
			$output.=" class=\"voted\"";
		}
		 $output.="> Rating: <strong> ".@number_format($current_rating/$count,1)."</strong>/$units($count $tense cast)";
		$output.="</p>
</div>
</div>";

		return $output;
}

function css_rating_js($atts="") {

	extract(lAtts(array(
			"js"=>""
		),$atts));

	if($js=="")
		$output="<script type=\"text/javascript\" src=\"/files/rating.js\"></script>";
	else
		$output="<script type=\"text/javascript\" src=\"/file_download/$js\"></script>";

return $output;
}
 

Neue Beiträge

Zurück