You have a couple of issues that once fixed will probably help you find the problem (or fix the problem. You arn't chomping the lines so you will have '5\n' instead of just '5' which is probably messing up the query. You are also using a C style loop instead of more perlish way that will require less variables ;) So here is your code with some minor changes that shouldn't break anything:
#!/usr/bin/perl use warnings; use strict; use DBIx::Simple; my $db = DBIx::Simple->connect('dbi:SQLite:dbname=mydatabase.db') or die DBIx::Simple->error; #switch to 3 arg form, no advantage here but its a good habit ;) open (WEBPAGESFORALL, "<", "webpages.txt") || die "couldn't open the f +ile!"; my @webpages = <WEBPAGESFORALL>; close(WEBPAGESFORALL); #remove trailing newlines chomp(@webpages); my @webpages_for_files; #print out the id's of the pages we want, seperated by commas print join(",", @webpages); #loop over the indexs we just grabbed from the file for (@webpages) { #push this page onto our list of saved pages. push @webpages_for_files, $db->query("SELECT webpage FROM webpages_d +ata WHERE id = ?", $_)->list; #change the query to use place holders } print join(",", @webpages_for_files); #three arg form open (WEBPAGES_OUT,">", "giveit.txt") || die "couldn't open the file!" +; foreach my $webp (@webpages_for_files) { print $webp ."\n"; } close(WEBPAGES_OUT);
In reply to Re: Script won't retrieve data from database
by eric256
in thread Script won't retrieve data from database
by lampros21_7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |