Results 1 to 8 of 8

Thread: won't add

  1. #1

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919

    won't add

    PHP Code:
        $result mysql_query("SELECT * FROM gallery WHERE id=$id");
                while(
    $row=mysql_fetch_array($result)){
                    
    $numvotes $row['numvotes'] + 1;
                    
    $newrating $row['rating'] + (int)rating;//thisline
                    
    $newrating /= $numvotes;
                    echo 
    "$numvotes  $newrating  $rating  $row[rating] <br>";
                } 
    "thisline" refuses to add, i can't figure out why

    rating is passed through GET. $row[numvotes] + 1 adds fine
    i tried casting it, thinking that would solve it, doesnt work either
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Wait...

    I'm not understanding the (int)rating thing. Should it be (int)$rating?

    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by The Hobo
    Wait...

    I'm not understanding the (int)rating thing. Should it be (int)$rating?

    I'm thinking just plain old $rating should do it. .... but then I'm not sure where rating came from either....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    I tried plain old $rating, didn't work

    It's from GET:
    $request = $_GET['request'];

    I thought that maybe it wasn't adding because it can't add an int/string together, so you had to cast it to int. Or maybe that's just in C++
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    that's just C++.

    hmm...I don't see how rating would work by itself. I thought you'd need to have $ infront of it to signify it's a variable. Does it give you any errors?

    Try this:

    Code:
    $newrating = $row['rating'] + $rating;
    echo "newrating = $newrating<br>"; //for testing
    $newrating /= $numvotes;
    Just to see if the last line isn't causing it. Debug it as much as possible, follow it through, and see where it gets you. That's about all I can suggest.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    hahaha i am an idiot. it didnt work because i didnt put a $ in front of rating. Jeebus
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by nabeels786
    hahaha i am an idiot. it didnt work because i didnt put a $ in front of rating. Jeebus
    Didn't we mention that up there?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    yes, i read that

Posting Permissions

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



Click Here to Expand Forum to Full Width