webtuto Posted January 10, 2008 Share Posted January 10, 2008 hi whats the error here => $web="SELECT SUM(`rate`) / COUNT(`rate`) from `rate`"; $tuto=mysql_query($web) or die('Database error: ' . mysql_error()); $mas=mysql_fetch_array($tuto); echo"The Rating of this tutorial is : ".$mas['rate']."<br><br>"; it douesnt show the result :s Link to comment https://forums.phpfreaks.com/topic/85411-whats-wrong-here/ Share on other sites More sharing options...
nikefido Posted January 10, 2008 Share Posted January 10, 2008 what error are you getting when you run the script? edit: im also bad with sql, but im guessing how you are doing math in the sql query is the problem Link to comment https://forums.phpfreaks.com/topic/85411-whats-wrong-here/#findComment-435775 Share on other sites More sharing options...
rlindauer Posted January 10, 2008 Share Posted January 10, 2008 You aren't returing "rate" from the sql query. $web="SELECT SUM(`rate`) / COUNT(`rate`) as rate from `rate`"; Link to comment https://forums.phpfreaks.com/topic/85411-whats-wrong-here/#findComment-435776 Share on other sites More sharing options...
Donovan Posted January 10, 2008 Share Posted January 10, 2008 hi whats the error here => $web="SELECT SUM(`rate`) / COUNT(`rate`) from `rate`"; $tuto=mysql_query($web) or die('Database error: ' . mysql_error()); $mas=mysql_fetch_array($tuto); echo"The Rating of this tutorial is : ".$mas['rate']."<br><br>"; it douesnt show the result :s I usually use and alias such as SELECT SUM(`rate`) AS rate_avg Link to comment https://forums.phpfreaks.com/topic/85411-whats-wrong-here/#findComment-435777 Share on other sites More sharing options...
webtuto Posted January 10, 2008 Author Share Posted January 10, 2008 so whats the solution it douesnt give any error Link to comment https://forums.phpfreaks.com/topic/85411-whats-wrong-here/#findComment-435779 Share on other sites More sharing options...
rlindauer Posted January 10, 2008 Share Posted January 10, 2008 so whats the solution it douesnt give any error $web="SELECT SUM(`rate`) / COUNT(`rate`) as rate from `rate`"; Link to comment https://forums.phpfreaks.com/topic/85411-whats-wrong-here/#findComment-435780 Share on other sites More sharing options...
webtuto Posted January 10, 2008 Author Share Posted January 10, 2008 thanks dude it works Link to comment https://forums.phpfreaks.com/topic/85411-whats-wrong-here/#findComment-435782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.