acp26b Posted January 28, 2007 Share Posted January 28, 2007 Here is my query:[code]$clientsquery = "Select COUNT(DISTINCT(c.clientid)) from clients c, accountbalances ab, accounts a, clientaccounts ca where ab.quarteryear = 'form_qy' and ab.accountid = a.accountid and a.accountid = ca.accountid and ca.clientid = c.clientid";$clientsresult = mysql_query($clientsquery);if(!$clientsresult){ $error_details = mysql_error(); errorhandler($error_details);}[/code]but i can not seem to pull the number out of the result i have tried:$db_clientnumber = mysql_result($clientsresult,0,"clientid");and$db_clientnumber = mysql_result($clientsresult,0,"COUNT(DISTINCT(c.clientid))");and$db_clientnumber = mysql_result($clientsresult,0,"COUNT(DISTINCT(clientid))");but i keep getting:Warning: mysql_result() [function.mysql-result]: COUNT(DISTINCT(clientid)) not found in MySQL result index 16 in C:\WEB_ROOT\clientpro\fta_summary.php on line 33(of course the error, looks a little different for each one i tried, but i did not copy them all over, same error though)Any ideas? Link to comment https://forums.phpfreaks.com/topic/36093-simple-but-frustrating/ Share on other sites More sharing options...
Orio Posted January 28, 2007 Share Posted January 28, 2007 Should be this way:[code]<?php$clientsquery = "Select COUNT(DISTINCT c.clientid) AS count FROM `clients c`, `accountbalances ab`, `accounts a`, `clientaccounts ca` WHERE ab.quarteryear = 'form_qy' AND ab.accountid = a.accountid AND a.accountid = ca.accountid AND ca.clientid = c.clientid";$clientsresult = mysql_query($clientsquery);if(!$clientsresult){ $error_details = mysql_error(); errorhandler($error_details);}else{ $db_clientnumber = mysql_result($clientresult, 0, "count");} ?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/36093-simple-but-frustrating/#findComment-171335 Share on other sites More sharing options...
acp26b Posted January 28, 2007 Author Share Posted January 28, 2007 Nice, forgot about AS :)Thanks! Link to comment https://forums.phpfreaks.com/topic/36093-simple-but-frustrating/#findComment-171340 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.