Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8419425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:36:26+00:00 2026-06-10T02:36:26+00:00

Well, this is my question. I need to insert data in the three tabblas

  • 0

Well, this is my question.

I need to insert data in the three tabblas nid, name, dir these are filtered from a file using regular expressions, and there are thousands, used a loop to do so in three in three.

content in file /home/lola/locatebookmarks

"date_added": "12988591842733282",
"id": "1706",
"name": "Xenode Systems Blog: \u00BFQu\u00E9 Hacer despu\u00E9s de instalar Fedora 15?",
"type": "url",
"url": "http://otrolink.com.ar/lola.html"
"date_added": "12988591842733884",
"id": "1707",
"name": "Install Google Chrome in Fedora 16 / 15 / 14 using YUM | HowOpenSource",
"type": "url",
"url": "http://www.howopenlola.com/2011/11/"
"date_added": "12988591842734487",
"id": "1708",
"name": "Linuxant - Linux drivers for Conexant chipsets - ALSA driver with improved support for Conexant chipsets",
"type": "url",
"url": "http://urlllola.com/alsa-driver/"

This code in perl.

use DBI;
use DBD::mysql;

$host = "localhost";
$database = "bookmarks";
$tablename = "test";
$user = "lola";
$pwd = "pass";
$connect = DBI->connect("DBI:mysql:$database:$host", $user, $pwd);

open(FILE, '/home/lola/locatebookmarks');
my @array;
my $var;
while ($i = <FILE>) {
    if ($i =~ /(id|name|http)/) {
        if ($i =~ s/("|:|,|name|id|url)//g) {
            ($key) = $i;
            push(@array, $var);
        }
    }
}
close(FILE);

$n=@array;
$n=($n/=3);
$count = 0;

for ($x = 0; $x < $n; $x++)  {
    while ($count <= 3) {
        $nid = pop(@array);
        $nombre = pop(@array);
        $dir = pop(@array);

        $query_insert = "INSERT INTO $tablename (nid, nombre, dir) 
        VALUES ('$nid', '$nombre', '$dir')";
        $query = $connect->prepare($query_insert);
        $query->execute();

    $count++;
    }
}

in mysql save this, but that bad, because save “,” !!

,                 Linuxant - Linux drivers for Conexant chipsets - ALSA driver with improved support for Conexant chipsets
,                 1708

,                 Install Google Chrome in Fedora 16 / 15 / 14 using YUM | HowOpenSource
,                 1707

,                 Xenode Systems Blog u00BFQuu00E9 Hacer despuu00E9s de instalar Fedora 15?
,                 1706

, ,  

If change in VALUES in code perl.

('$nid', '$nombre', '$dir')"; > VALUES ('$nid' '$nombre' '$dir')";

Its error, in console.

DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at exp-b.pl line 38.
DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at exp-b.pl line 38.
DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at exp-b.pl line 38.
DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at exp-b.pl line 38.

I need in mysql.

        nid         nombre      dir

       1708         Linuxant - Linux drivers for Conexant chipsets - ALSA driver with improved support for Conexant chipsets    http://urlllola.com/alsa-driver/
       1707      Install Google Chrome in Fedora 16 / 15 / 14 using YUM | HowOpenSource     http://www.howopenlola.com/2011/11/
       1706         Xenode Systems Blog: \u00BFQu\u00E9 Hacer despu\u00E9s de instalar Fedora 15?       http://otrolink.com.ar/lola.html

I hope you understand , greetings

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:36:27+00:00Added an answer on June 10, 2026 at 2:36 am

    So this:

    open(FILE, '/home/lola/locatebookmarks');
    my @array;
    my $var;
    while ($i = <FILE>) {
        if ($i =~ /(id|name|http)/) {
            if ($i =~ s/("|:|,|name|id|url)//g) {
                ($key) = $i;
                push(@array, $var);
            }
        }
    } 
    close(FILE);
    

    Never sets any value into $var, so when you push it onto @array, you’re pushing nothing. So you probabaly want to push either $i onto @array and forget about $key.

    This:

    $n=($n/=3);
    

    should probably be:

    $n /= 3
    

    and I second @TLP regarding using placeholders instead of variable interpolation in the SQL.

    $query_insert = "INSERT INTO $tablename (nid, nombre, dir) 
    VALUES ('$nid', '$nombre', '$dir')";
    $query = $connect->prepare($query_insert);
    $query->execute();
    

    becomes:

    $query_insert = "INSERT INTO $tablename (nid, nombre, dir) VALUES (?, ?, ?)";
    $query = $connect->prepare($query_insert);
    $query->execute($nid, $nombre, $dir);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to load data from a single file with a 100,000+ records into multiple
First, I don't know where to ask this question. Well this is programming QA
Well this is a simple question i want to filter two elements sorted reverse
I believe this question applies equally well to C# as to Java, because both
I know this question may well be the silliest question you've heard today, but
I hope this question isn't too general. Well, the situation is that I am
Well, I tried to ask this question as a comment on this question, but
Well, first of all sorry about this question it must be pretty straight forward
Well, I'm learning Scala so this question may be too basic for most people.
Well! I feel really stupid for this question, and I wholly don't mind if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.