If you provide more information, it is easier to determine where the error is.
You did not check the result of your prepares and executes like you did the connects,
either wirh explicit error checks or with RaiseError = 1 or at least PrintError = 1.
Did the prepares and executes work? If you don't check for errors, how do you know?
Were there any error messages or other output from the program? You did not say.
What are the values of $access and are those records in the database?
This does not sound like the problem you described, but shouldn't
WHERE idnum='Sally");#need to work for all the updated files, not just one file
have a closing appostrophe for 'Sally'
WHERE idnum='Sally'");#need to work for all the updated files, not just one file
Another side issue - you connected three times, but only disconnected one database
handle.
Try checking for errors and printing the error messages and you may be able to debug
it on your own, or at least give people enough error messages and other information to
be able to help you.
A L wrote:
> Dear [EMAIL PROTECTED],
>
> Okay, so, by being ignored, it dawned on me that my question may have been
> considered to be stupid. But, since my goal is to program better, more time was
> spent, even though spending a whole week checking the code and looking at whatever
> books could be found to figure out what was wrong with it (thinking it should have a
> simple solution) didn't produce any result .
>
> Although my code does function when WHERE in the prepare statement is specified
> within a database, it isn't exactly what was intended. This code should
> automatically update all the rows when there are matching idnum with same file name
> without having to type specific name for WHERE (for example, not WHERE='Sally" but
> WHERE=?). With another program example, which uses the same prepare and excute
> statement format as this code, the code works, but not in this program. Both
> program looks the same to me, but this one isn't working. And, I can't figure out
> why.
>
> It really would help me a lot if you would spend a little bit of time to show me why
> it's not working, even if you find this question to be stupid. To me it is not, it
> is important to me to understand why I don't get this. Any feedback would be much
> appreciated.
> Angela
>
> #!/usr/bin/perl
> use DBI;
> my $dbh = DBI->connect("dbi:mysql:", "usrname", "password") || die $DBI::errstr;
> my $db_database = DBI->connect("dbi:mysql:database", "usrname", "password") || die
> $DBI::errstr;
> my $insert_database=$db_database->prepare("INSERT INTO table1 values
> (?,?,?,?,?,?,?)");
> my $dbh1 = DBI->connect("dbi:mysql:database", "usrname", "password") || die
> $DBI::errstr;
> my $lookup_access=$dbh1->prepare("select retrieval_date FROM table1 WHERE idnum=
> ?");
>
> $Top="/home/Top/";
> chdir $Top;
> my $count=0;
> while (my $subdir=<*>){
> chdir $subdir;
> while (my $file=<*.txt>){
> $file=~/^(\w*)./;
> my $access=$1;
> $lookup_access->execute($access);
> my @result=$lookup_access->fetchrow();
> my @file=stat("$access.txt");
> my $mtime=$file[9];
> my @testime=gmtime($mtime) ;
> my $year=$testime[5]+1900;
> my $mon=$testime[4]+1;
> my $mday=$testime[3];
> my $mon=sprintf("%02d",$mon);
> my $mday=sprintf("%02d",$mday);
> my $date= "$year-$mon-$mday";
> if (@result){
> my $result=$date;
> if ($result){
> my $update_table1=$dbh1->prepare(
> "UPDATE table1
> SET retrieval_date='$result'
> WHERE idnum='Sally");#need to work for all the updated files, not just one file
> $update_table1->execute();
> }
> }
> }
> chdir "..";
>
> }
> $dbh->disconnect;
>
> ---------------------------------
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
--
James D. White ([EMAIL PROTECTED])
Department of Chemistry and Biochemistry
University of Oklahoma
620 Parrington Oval, Room 313
Norman, OK 73019-3051
Phone: (405) 325-4912, FAX: (405) 325-7762