Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

103 users online



sum trouble

sum trouble

Currently viewing this thread: 1 (0 members and 1 guests)


doolally

doolally

Neverside Newbie
Status: Offline!

sum trouble

If got this query ("SELECT sum(comment_rating) AS total From comments WHERE link_name='affilate'") that works fine when I run it through phpmyadmin but I just can't echo it.

PHP:

<?php
$query 
"SELECT sum(comment_rating) AS total From comments WHERE link_name='affilate'";
$result mysql_query($query);
$row mysql_fetch_row($result);
echo 
$row['total'];
?>

whats wrong?

___________________

Comming soon.....The Lord of The Links

sabrina

sabrina

what could you possibly want to know about me?
Status: Offline!

That's because mysql_fetch_row returns an enumerated array - if you
want to refer to the result by $row['total'] (rather than $row[0]) use
mysql_fetch_array instead.

doolally

doolally

Neverside Newbie
Status: Offline!

sabrina,

Thanks you've been a great help, now I can stop banging my head against the wall.

Cheers,

___________________

Comming soon.....The Lord of The Links

epyon

epyon

16, staying Asian.
Status: Offline!

great pun Grin

___________________

http://whatpulse.bounceme.net/sig/epyon.png

Rad

Rad

thinking of something witty to put here
Status: Offline!

For retrieving a single value use mysql_result instead as it will work faster.

PHP:

<?php

$sum 
mysql_result($result0);
echo 
$sum;

?>

doolally

doolally

Neverside Newbie
Status: Offline!

Radley,

Cheers

___________________

Comming soon.....The Lord of The Links

Adam

Adam

Status: Offline!

always die on mysql_error() when you do a query, ALWAYS

___________________


Current Project: LivermoreMuscle.com
Sig Hosted by Motorspin

doolally

doolally

Neverside Newbie
Status: Offline!
Quote:

Originally posted by Adam
always die on mysql_error() when you do a query, ALWAYS

Cheers Adam

___________________

Comming soon.....The Lord of The Links

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0079 seconds.