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 Quote 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 Quote 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`"; Quote 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 Quote 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 Quote 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`"; Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/85411-whats-wrong-here/#findComment-435782 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.