Hallo,
ich habe ein kleines Problem mit der Ajax Star Rating Bar und hoffe dass mir evtl. hier jemand weiterhelfen kann.
Und zwar zeigt es mir folgende Fehlermeldung an:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-vote4dogs.ratings WHERE id='8xxa'' at line 1
Siehe auch: http://vote4dogs.de/voting.php (am Ende der Seite).
Gruß,
Gina
Ankündigung
Einklappen
Keine Ankündigung bisher.
Ajax Star Rating Bar Problem
Einklappen
Neue Werbung 2019
Einklappen
Dieses Thema ist geschlossen.
X
X
-
Ajax Star Rating Bar Problem
Stichworte: -
-
Und vor allem leisten wir hier keinen Support für Scripte, wende dich doch an den Author.
Einen Kommentar schreiben:
-
Das liegt daran das man in Datenbank namen man einfach keine - oder sonstige Mysql Sonderzeichen benutz.
Einen Kommentar schreiben:
-
_drawrating.php
PHP-Code:<?php
/*
Page: _drawrating.php
Created: Aug 2006
Last Mod: Mar 18 2007
The function that draws the rating bar.
---------------------------------------------------------
ryan masuga, masugadesign.com
ryan@masugadesign.com
Licensed under a Creative Commons Attribution 3.0 License.
http://creativecommons.org/licenses/by/3.0/
See readme.txt for full credit details.
--------------------------------------------------------- */
function rating_bar($id,$units='',$static='') {
require('_config-rating.php'); // get the db connection info
//set some variables
$ip = $_SERVER['REMOTE_ADDR'];
if (!$units) {$units = 10;}
if (!$static) {$static = FALSE;}
// get votes, values, ips for the current rating bar
$query=mysql_query("SELECT total_votes, total_value, used_ips FROM $rating_dbname.$rating_tableName WHERE id='$id' ")or die(" Error: ".mysql_error());
// insert the id in the DB if it doesn't exist already
// see: http://www.masugadesign.com/the-lab/scripts/unobtrusive-ajax-star-rating-bar/#comment-121
if (mysql_num_rows($query) == 0) {
$sql = "INSERT INTO $rating_dbname.$rating_tableName (`id`,`total_votes`, `total_value`, `used_ips`) VALUES ('$id', '0', '0', '')";
$result = mysql_query($sql);
}
$numbers=mysql_fetch_assoc($query);
if ($numbers['total_votes'] < 1) {
$count = 0;
} else {
$count=$numbers['total_votes']; //how many votes total
}
$current_rating=$numbers['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=mysql_num_rows(mysql_query("SELECT used_ips FROM $rating_dbname.$rating_tableName WHERE used_ips LIKE '%".$ip."%' AND id='".$id."' "));
// now draw the rating bar
$rating_width = @number_format($current_rating/$count,2)*$rating_unitwidth;
$rating1 = @number_format($current_rating/$count,1);
$rating2 = @number_format($current_rating/$count,2);
if ($static == 'static') {
$static_rater = array();
$static_rater[] .= "\n".'<div class="ratingblock">';
$static_rater[] .= '<div id="unit_long'.$id.'">';
$static_rater[] .= '<ul id="unit_ul'.$id.'" class="unit-rating" style="width:'.$rating_unitwidth*$units.'px;">';
$static_rater[] .= '<li class="current-rating" style="width:'.$rating_width.'px;">Currently '.$rating2.'/'.$units.'</li>';
$static_rater[] .= '</ul>';
$static_rater[] .= '<p class="static">'.$id.'. Rating: <strong> '.$rating1.'</strong>/'.$units.' ('.$count.' '.$tense.' cast) <em>This is \'static\'.</em></p>';
$static_rater[] .= '</div>';
$static_rater[] .= '</div>'."\n\n";
return join("\n", $static_rater);
} else {
$rater ='';
$rater.='<div class="ratingblock">';
$rater.='<div id="unit_long'.$id.'">';
$rater.=' <ul id="unit_ul'.$id.'" class="unit-rating" style="width:'.$rating_unitwidth*$units.'px;">';
$rater.=' <li class="current-rating" style="width:'.$rating_width.'px;">Currently '.$rating2.'/'.$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
$rater.='<li><a href="db.php?j='.$ncount.'&q='.$id.'&t='.$ip.'&c='.$units.'" title="'.$ncount.' out of '.$units.'" class="r'.$ncount.'-unit rater" rel="nofollow">'.$ncount.'</a></li>';
}
}
$ncount=0; // resets the count
$rater.=' </ul>';
$rater.=' <p';
if($voted){ $rater.=' class="voted"'; }
$rater.='>'.$id.' Rating: <strong> '.$rating1.'</strong>/'.$units.' ('.$count.' '.$tense.' cast)';
$rater.=' </p>';
$rater.='</div>';
$rater.='</div>';
return $rater;
}
}
?>
Einen Kommentar schreiben:
-
Das ist schon mal ein Anfang, aber was steht in den ersten Zeilen von _drawrating.php? Da ist ja anscheinend der Fehler! Tabellen existieren alle?
Wolf29
Einen Kommentar schreiben:
-
Programm:
Unobtrusive AJAX Star Rating Bar | Masuga Design - Web Design and Development Located in Grand Rapids, MI
Script:
Bewertungs Sterne erstellen mit Ajax Star Rating Bar | Web:Manual
bzw.
Code:--->INSTALLATION: ====================================================================== ======= 1. Make your table for the ratings in your db (you should be able to copy and paste the following SQL) ====================================================================== ======= CREATE TABLE `ratings` ( `id` varchar(11) NOT NULL, `total_votes` int(11) NOT NULL default 0, `total_value` int(11) NOT NULL default 0, `used_ips` longtext, PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=3; ====================================================================== ======= 2. Enter your specific info into _config-rating.php ====================================================================== ======= $dbhost = 'localhost'; $dbuser = '###'; $dbpass = '###'; $dbname = '###'; $tableName = 'ratings'; $rating_unitwidth = 30; ====================================================================== ======= 3. Enter this line at the top of any page where you want to have rating bars. ====================================================================== ======= <?php require('_drawrating.php'); ?> ====================================================================== ======= 4. Point to the right Javascript and CSS files (you need behavior.js, rating.js, and rating.css) ====================================================================== ======= <script type="text/javascript" language="javascript" src="js/behavior.js"></script> <script type="text/javascript" language="javascript" src="js/rating.js"></script> <link rel="stylesheet" type="text/css" href="css/rating.css" /> Remember to make sure to fix paths for the images as well. I kept behavior.js separate from rating.js, because you can use it for other things! ====================================================================== ======= 5. Drop the function wherever you want a rating bar to appear ====================================================================== ======= NOTE: As of version 1.2.1, use the echo statement! Also, if you use the static parameter, you should always specify the 2nd parameter (number of units), even if it is blank (which will default to 10 units) <?php echo rating_bar('8'); ?> - 10 stars (default), ID of 8 <?php echo rating_bar('8xxa','5'); ?> - 5 stars, ID of 8xxa <?php echo rating_bar('9a','5','static'); ?> - 5 stars, ID of 9a, static (non votable) <?php echo rating_bar('9b',''); ?> - 10 stars, ID of 9b <?php echo rating_bar('9c','8','static'); ?> - 8 stars, ID of 9c, static (non votable) If you want to change how the rating bar is rendered, you will need to edit the _drawrating.php file. Also, you might need to edit the bottom of the rpc.php file at about line 52, where the $newback variable is.
PHP-Code:<?php require('ajaxstarrater/_drawrating.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Vote4Dogs.de - Vote für den lustigsten Hund!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Vote4Dogs.de | Vote für den lustigsten Hund!">
<meta name="keywords" content="Voten, Bildervoting, Bilder bewerten, Bilder, Fotos, Hundebilder, Hundefotos, Rottweiler, Shar Pei, Labrador, Schäferhund, vote4dogs">
<meta http-equiv="pragma" content="no-cache">
<meta name="robots" content="INDEX,FOLLOW">
<meta name="revisit-after" content="30 days">
<link rel="stylesheet" href="emx_nav_left.css" type="text/css" />
<script type="text/javascript" language="javascript" src="ajaxstarrater/js/behavior.js"></script>
<script type="text/javascript" language="javascript" src="ajaxstarrater/js/rating.js"></script>
<link rel="stylesheet" type="text/css" href="ajaxstarrater/css/rating.css" />
</script></head>
<body onmousemove="closesubnav(event);">
<div class="skipLinks">skip to: <a href="#content">page content</a> | <a href="#pageNav">links on this page</a> | <a href="#globalNav">site navigation</a> | <a href="#siteInfo">footer (site information)</a> </div>
<div id="masthead">
<h1 id="siteName">Vote4Dogs</h1>
<div id="utility"> <a href="mailto:webmaster@vote4dogs.de">Kontakt</a> | <a href="impressum.html">Impressum</a> </div>
<div id="globalNav"> <img alt="" src="gblnav_left.gif" height="32" width="4" id="gnl" /> <img alt="" src="glbnav_right.gif" height="32" width="4" id="gnr" />
<div id="globalLink"> <a href="start.html" id="gl1" class="glink" onmouseover="ehandler(event,menuitem1);">Startseite</a><a href="news.html" id="gl2" class="glink" onmouseover="ehandler(event,menuitem2);">NEWS</a><a href="voting.html" id="gl3" class="glink" onmouseover="ehandler(event,menuitem3);">Voting</a><a href="newpix.html" id="gl4" class="glink" onmouseover="ehandler(event,menuitem4);">Neueste Bilder</a><a href="maerz2010.html" id="gl5" class="glink" onmouseover="ehandler(event,menuitem5);">Hund des Monats </a><a href="aufbau.html" id="gl6" class="glink" onmouseover="ehandler(event,menuitem6);">Forum</a><a href="gbook.html" id="gl7" class="glink" onmouseover="ehandler(event,menuitem7);">Gästebuch</a> </div>
</div>
<div id="subglobal2" class="subglobalNav"> <a href="news.html">März 2010</a> | <a href="news.html">April 2010</a></div>
<div id="subglobal3" class="subglobalNav"> <a href="voting.html">März 2010</a> | <a href="voting.html">April 2010</a></div>
<div id="subglobal4" class="subglobalNav"> <a href="newpix.html">März 2010</a> | <a href="newpix.html">April 2010</a></div>
<div id="subglobal5" class="subglobalNav"> <a href="maerz2010.html">März 2010</a> | <a href="april2010.html">April 2010</a></div>
</div>
<div id="pagecell1">
<img alt="" src="tl_curve_white.gif" height="6" width="6" id="tl" /> <img alt="" src="tr_curve_white.gif" height="6" width="6" id="tr" />
<div id="breadCrumb">Aktuell / <a href="voting.html">Voting</a></div>
<div id="pageName">
<h2>Vote4Dogs - Vote für das lustigste Hundebild! </h2>
</div>
<div id="pageNav">
<div id="sectionLinks"> <a href="start.html">Startseite</a> <a href="news.html">Neuigkeiten</a> <a href="aufbau.html">Forum</a> <a href="aufbau.html">Mitglieder</a> <a href="links.html">Links</a> <a href="gbook.html">Gästebuch</a> </div>
<div class="relatedLinks">
<h3>Aktuell</h3>
<a href="voting.html">Voting </a> <a href="newpix.html">Neueste Bilder </a></div>
<div class="relatedLinks">
<h3>Hund des Monats</h3>
<a href="maerz2010.html">März 2010</a> <a href="april2010.html">April 2010</a></div>
<div class="relatedLinks">
<h3>Hunderassenbilder</h3>
<a href="mischlinge.html">Mischlinge</a> <a href="rottweiler.html">Rottweiler</a> <a href="sharpei.html">Shar Pei</a></div>
<div id="advert"> Neuestes Bild: <img src="pix/picomat/01.jpg" alt="" width="154" height="108" /></div>
</div>
<div id="content">
<div class="feature">
<p align="justify"><strong>Hunde die im März am Voting teilnehmen:</strong>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>#01 Ach isch des hier bequem!! (Name: Yogi, Rasse: brushcoat Shar Pei)</td>
</tr>
<tr>
<td><img src="pix/voting/maerz/01yogi.JPG" width="480" height="335" /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>#02 Hab's ja gesagt, ich pass rein... (Name: Celine, Rasse: bearcoat Shar Pei)</td>
</tr>
<tr>
<td><img src="pix/voting/maerz/02celine.JPG" width="480" height="335" /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>#03 Wo sind denn nur die Ostereier versteckt? (von Bieries)</td>
</tr>
<tr>
<td><img src="pix/voting/maerz/03bieries.jpg" width="480" height="335" /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<?php echo rating_bar('8','5'); ?></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<p align="justify">
</div>
<div class="story"></div>
</div>
<div id="siteInfo">
<p><img src="" width="44" height="22" /> <a href="mailto:webmaster@vote4dogs.de">Kontakt</a> | <a href="impressum.html">Impressum</a> | ©2010 Vote4Dogs </p>
</div>
</div>
<br />
<script type="text/javascript">
var menuitem1 = new menu(7,1,"hidden");
var menuitem2 = new menu(7,2,"hidden");
var menuitem3 = new menu(7,3,"hidden");
var menuitem4 = new menu(7,4,"hidden");
var menuitem5 = new menu(7,5,"hidden");
var menuitem6 = new menu(7,6,"hidden");
var menuitem7 = new menu(7,7,"hidden");
</script>
</body>
</html>
Einen Kommentar schreiben:
-
Tja, das übliche Problem: ohne Quellcode können wir nur raten. Zu mindestens kann ich Dir sagen, dass dein SQL Statement nicht stimmt!
Wolf29
Einen Kommentar schreiben:
-
Script und warscheinlich gibt es keine ID "8xxa", da IDs meist nut Zahlen sind.
Einen Kommentar schreiben:
Einen Kommentar schreiben: