Jump to content

Simple but frustrating!


acp26b

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.