I need some expert troubleshooting assistance running and ODBC-based
query. When running my query I receive the error message "WARNING:
2 is not a valid ODBC result resource in C:\Access\LATAsByNPA.php
on line 9"
My goal is to work with two fields. I want to identify all the unique
values in the NPA field and list the associated LATAs.
The table LATAsByNPA has two Char(3) fields with sample data as follows:
NPA LATA
202 236
202 238
202 256
203 333
204 444
204 555
The desired output is:
activities.202 = new Array("236","238","256"," ");
activities.203 = new Array("333"," ");
activities.204 = new Array("444","555"," ");
The code I am using and results follow:
1 <?PHP
2 $query = "SELECT distinct npa FROM latasbynpa order by npa";
3 $hostname = "lerg";
4 $username = "";
5 $password = "";
6 $connect = odbc_connect($hostname, $username, $password);
7 $connect2 = odbc_connect($hostname, $username, $password);
8 $result = odbc_exec($connect, $query);
9 while(odbc_fetch_row($result))
10 { $query2 = "SELECT distinct lata FROM latasbynpa where npa='" .
11 odbc_result($result, "npa") . "' order by lata";
12 $result2 = odbc_exec($connect2, $query2);
13 print "activities." . odbc_result($result, "npa") . " = new Array(" ;
14 while(odbc_fetch_row($result2)){print '"' . odbc_result($result2, "lata") . '",';}
15 print '" "); <BR>' ;
16 odbc_close($connect2);
17 }
18 odbc_close($connect);
19 ?>
When ran as-is, I receive the following output:
activities.202 = new Array("236","238","256"," ");
"WARNING: 2 is not a valid ODBC result resource in C:\Access\LATAsByNPA.php
on line 9"
This means that it is finding the first occurance of NPA and the related LATAs. It is
simply failing to cycle through the rest of the NPAs.
By commenting out lines 12, 14 & 16. I get the following output:
activities.202 = new Array(" ");
activities.203 = new Array(" ");
activities.204 = new Array(" ");
The good news here is that the process to cycle through NPAs is working; however,
the query to list associated LATAs is disabled.
QUESTION: How do I enable the script to cycle through NPAs and list associated
LATAs??
Please respond in the newsgroup or email wadkins@virtucorp.org
TIA!
-Will