$v = 0; # The v variable will now be used with the database my $dbh = DBI->connect( "dbi:SQLite:dbname=mydatabase.db", "", "" )|| + die "Cannot connect: DBI"; # If the file exists delete the information in it eval { local $dbh->{PrintError} = 0; $dbh->do("DROP TABLE webpages_data"); }; # Create a table $dbh->do( "CREATE TABLE webpages_data (id INTEGER PRIMARY KEY, page, +text, bigr)"); my $a = 1; while(@links) { $dbh->do( "INSERT INTO webpages_data VALUES('$a', '$_', '$text[$v +]', NULL)"); $a++; $v++; } # Disconnect when finished using the database $dbh->disconnect();
I have an array @text so the $v variable is to get the string inside each element of array and try to put it in the database table. The $a variable is to give a unique ID to each row in the table. These two variables work by adding to them 1 every time the loop is due to start again. I also want to keep the 4th column with a NULL value
The problem is i get an error "Use of uninitialized value in concatenation (.) or string". This comes from the INSERT INTO line. I have found previous posts that had this error but none of the solutions seem to help with this situation.
I have also downloaded the SQLite analyser program to see what is in my table but it doesn't bring up anything so i presume the information doesn;t get written in the database file
Any ideas? Thanks
In reply to How do I write data in SQLite by lampros21_7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |