Subject | firebird15/ADOdb |
---|---|
Author | dleec45 |
Post date | 2004-05-28T23:42:45Z |
Lester, I'm trying to use the Fields() function and have tried all the
variations I can think of and am getting nothing returned. I'm trying
to load a zip table with 3 fields (STID, ZIP, CITY), and have a small
table set up for testing with about 5 entries in it that match the
first 5 in input file. The app is simple, reads an input file, strips
out the commas, echos data, builds a qry with the zip in it, look to
see if the zip already exists, if not add to table, otherwise, keep
on. Here the code I have. Can you see what's wrong with this??
foreach ($data as $l)
{
// split on comma and echo results
$ar0 = '';
$arr = explode(",", $l);
$ar0 = $arr[0]; // STID - state ID
$ar1 = $arr[1]; // ZIP
$ar2 = $arr[2]; // CITY
echo $ar0 . " " . $ar1 . " " .$ar2 . " " . "\n";
// Build query with zip code to see if it already exists
$qry = "'" . 'SELECT * from bigzip WHERE STID = ';
$qry = $qry . "$ar1" . "'";
echo $qry ."\n";
// Execute the query to locate the zip code and echo what we found
$rs = $db->Execute($qry);
echo $rs->fields[0] . "dlc"."\n";
echo $rs->fields[1] . "dlc"."\n";
echo $rs->fields[2] . "dlc"."\n";
echo $rs->fields['STID'] . "dlc"."\n";
echo $rs->fields['ZIP'] . "dlc"."\n";
echo $rs->fields['CITY'] . "dlc"."\n";
and here's a sample of the output:
AK 99501 ANCHORAGE
'SELECT * from bigzip WHERE STID = 99501'
dlc
dlc
dlc
dlc
dlc
dlc
AK 99502 ANCHORAGE
'SELECT * from bigzip WHERE STID = 99502'
dlc
dlc
dlc
dlc
dlc
dlc
AK 99503 ANCHORAGE
'SELECT * from bigzip WHERE STID = 99503'
dlc
dlc
dlc
dlc
dlc
dlc
I've tried the query as built in a db utility and it works OK. Any
suggestions?
variations I can think of and am getting nothing returned. I'm trying
to load a zip table with 3 fields (STID, ZIP, CITY), and have a small
table set up for testing with about 5 entries in it that match the
first 5 in input file. The app is simple, reads an input file, strips
out the commas, echos data, builds a qry with the zip in it, look to
see if the zip already exists, if not add to table, otherwise, keep
on. Here the code I have. Can you see what's wrong with this??
foreach ($data as $l)
{
// split on comma and echo results
$ar0 = '';
$arr = explode(",", $l);
$ar0 = $arr[0]; // STID - state ID
$ar1 = $arr[1]; // ZIP
$ar2 = $arr[2]; // CITY
echo $ar0 . " " . $ar1 . " " .$ar2 . " " . "\n";
// Build query with zip code to see if it already exists
$qry = "'" . 'SELECT * from bigzip WHERE STID = ';
$qry = $qry . "$ar1" . "'";
echo $qry ."\n";
// Execute the query to locate the zip code and echo what we found
$rs = $db->Execute($qry);
echo $rs->fields[0] . "dlc"."\n";
echo $rs->fields[1] . "dlc"."\n";
echo $rs->fields[2] . "dlc"."\n";
echo $rs->fields['STID'] . "dlc"."\n";
echo $rs->fields['ZIP'] . "dlc"."\n";
echo $rs->fields['CITY'] . "dlc"."\n";
and here's a sample of the output:
AK 99501 ANCHORAGE
'SELECT * from bigzip WHERE STID = 99501'
dlc
dlc
dlc
dlc
dlc
dlc
AK 99502 ANCHORAGE
'SELECT * from bigzip WHERE STID = 99502'
dlc
dlc
dlc
dlc
dlc
dlc
AK 99503 ANCHORAGE
'SELECT * from bigzip WHERE STID = 99503'
dlc
dlc
dlc
dlc
dlc
dlc
I've tried the query as built in a db utility and it works OK. Any
suggestions?