PDA

View Full Version : Star Rating Images



mobilebadboy
05-08-2004, 06:29 AM
When trying to implement the Star Rating Images (http://www.websitepublisher.net/article/aws-addons/), I get the following error:

Fatal error: Unsupported operand types

This line is the line causing the error: $width = $Rating * 13;

I've moved it different places, tried all sorts of stuff with it and nothing gets rid of the error. I've tried to get it to work before with no luck, so now I decided to finally post about it because I'd like to figure out the problem.

r2d2
05-08-2004, 07:57 AM
Are you sure $rating is a number not a string? You may need to convert it to a number first ie:

$width = floatval($Rating) * 13;

Edit: Guess you might want to use intval() if its for a px width..

mobilebadboy
05-08-2004, 08:02 AM
$Rating is actually an array, but I was just copying the code exactly as it appears on that page.

edit: Both floatval and intval didn't produce an error, but it's only showing 1 star (out of 5) for all ratings. 13px.

r2d2
05-08-2004, 08:41 AM
Try looping through the values then:



for ($i = 0; $i < num_vals; $i++) {
$width[$i] = intval($Rating[$i]) * 13;
}


Where num_vals is the number of values in ur array.

mobilebadboy
05-08-2004, 08:51 AM
Well, that's weird. It's showing 5 stars, for everything now.

But there's actually no value assigned (style = "width: px;"). Heh.

mobilebadboy
05-08-2004, 09:27 AM
Well, since I couldn't figure it out, I just took the failsafe and ran an if/else 1-5 since the single reviews seem to always be a whole number. That doesn't work for the average customer rating since it's not, but at least I'm part way there.