Results 1 to 6 of 6

Thread: Star Rating Images

  1. #1
    Roll Tide! mobilebadboy's Avatar
    Join Date
    Apr 2004
    Location
    Mobile, AL
    Posts
    428

    Star Rating Images

    When trying to implement the Star Rating Images, 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.
    Shawn Kerr .com

  2. #2
    Future AstonMartin driver r2d2's Avatar
    Join Date
    Dec 2003
    Location
    UK
    Posts
    1,608
    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..
    Last edited by r2d2; 05-08-2004 at 08:02 AM.

  3. #3
    Roll Tide! mobilebadboy's Avatar
    Join Date
    Apr 2004
    Location
    Mobile, AL
    Posts
    428
    $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.
    Last edited by mobilebadboy; 05-08-2004 at 08:05 AM.
    Shawn Kerr .com

  4. #4
    Future AstonMartin driver r2d2's Avatar
    Join Date
    Dec 2003
    Location
    UK
    Posts
    1,608
    Try looping through the values then:

    PHP Code:
    for ($i 0$i num_vals$i++) {
         
    $width[$i] = intval($Rating[$i]) * 13;

    Where num_vals is the number of values in ur array.

  5. #5
    Roll Tide! mobilebadboy's Avatar
    Join Date
    Apr 2004
    Location
    Mobile, AL
    Posts
    428
    Well, that's weird. It's showing 5 stars, for everything now.

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

  6. #6
    Roll Tide! mobilebadboy's Avatar
    Join Date
    Apr 2004
    Location
    Mobile, AL
    Posts
    428
    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.
    Shawn Kerr .com

Similar Threads

  1. Free Royalty Free Images
    By incka in forum HTML, CSS, Layout, and Design
    Replies: 31
    Last Post: 01-22-2005, 10:07 AM
  2. ASP - Display random images
    By MattM in forum Website Programming & Databases
    Replies: 1
    Last Post: 03-22-2004, 03:47 PM
  3. Images that stretch
    By Duke in forum Graphics & Multimedia
    Replies: 8
    Last Post: 02-01-2004, 04:16 PM
  4. Attaching images?
    By Best.Flash in forum Site and Forum Feedback
    Replies: 1
    Last Post: 01-22-2004, 07:17 AM
  5. Deeper into Stretching images..
    By Jaffro in forum Graphics & Multimedia
    Replies: 3
    Last Post: 01-19-2004, 05:29 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •