ok I declared the vars and now I'm getting a different type of error:

DBD::Sybase::db do failed: Server message number=170 severity=15 state=1
line=1 server=WHITETAIL text=Line 1: Incorrect syntax near 'new'. at
../zip.pl line 36.
Can't call method "execute" on an undefined value at ./zip.pl line 37.


Current code:

#!/usr/bin/perl -w
use LWP::Simple;
use DBI;
use strict;
my $db="zipcodes";              #############
my $user="notshown";            # Database  #
my $pass="notshown";            # Variables #
my $tablename="zips";   #############
my $insertToDB=1; #Change to zero if you don't want to write to DB
my $printToTerm=1; #Change to zero if you don't want results printed to the
terminal
my $content;
my @arr;
my @new;
my $line;
my $count=0;
my $dbh;
my $action;

$_=get("http://zipinfo.com/cgi-local/zipsrch.exe?cnty=cnty&ac=ac&zip=08550";)
;# Get Zipcode Data
@arr = /<td align=center>(.*?)<\/td>/g; # Stript Most HTML
shift(@arr); #Remove Unwanted
shift(@arr); #Data Returned
# Strip trailing </font> tag, remove fips code, and Store in array
foreach $line(@arr){
        $_=$line;
        /(.*.)<(.....)/;
        if($count != 6){
        $new[$count]=$1;
        ++$count;
        }
}
# Insert Data into Database MS SQL SERVER 2K
if($insertToDB==1){
        $dbh = DBI->connect('DBI:Sybase:server=192.168.0.2', $user, $pass);
        $dbh->do('INSERT into
zips(city,state,county,zip,areacode)VALUES($new[0],$new[1],$new[3],$new[2],$
new[5])');
        $action->execute || die print "$! - DB Error";
}
# Print to Terminal
if($printToTerm==1){
print "@new\n";
}

-----Original Message-----
From: Crook, Richard W [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 4:55 PM
To: 'Michael Gargiullo'; Beginners
Subject: RE: Connecting to DB


Looks like you need to declare my $dbh, my $action, my $passwd up where
you've declared the others or just turn off strict.
To debug your database statement try: die $action to see what the script is
sending to the database

-----Original Message-----
From: Michael Gargiullo [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 28, 2002 1:31 PM
To: Beginners
Subject: FW: Connecting to DB


OK I have the following array

@new which has the following data in it
        this town
        this state
        zipcode
        county
        fips (I want discarded)
        Area code

And want to insert these vars into my DB

I'm using this code:

<snip>Old Code</snip


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to