|
-
Nov 26th, 2002, 02:38 PM
#1
Thread Starter
Fanatic Member
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?
-
Nov 26th, 2002, 03:47 PM
#2
Stuck in the 80s
Wait...
I'm not understanding the (int)rating thing. Should it be (int)$rating?
-
Nov 26th, 2002, 03:52 PM
#3
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....
-
Nov 26th, 2002, 03:59 PM
#4
Thread Starter
Fanatic Member
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?
-
Nov 26th, 2002, 04:07 PM
#5
Stuck in the 80s
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.
-
Nov 27th, 2002, 09:51 AM
#6
Thread Starter
Fanatic Member
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?
-
Nov 27th, 2002, 10:04 AM
#7
Stuck in the 80s
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?
-
Nov 29th, 2002, 09:05 AM
#8
Conquistador
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|