Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^3: Use of uninitialized value in join or string

by hippo (Monsignor)
on Jan 29, 2014 at 13:20 UTC ( #1072506=note: print w/replies, xml ) Need Help??

in reply to Re^2: Use of uninitialized value in join or string
in thread Use of uninitialized value in join or string

Your code snippet here isn't actually using placeholders, so you may not have quite grasped what they are. See how roboticus is using the question marks in his SQL? See how he calls execute with the field list? These are things which you should be doing.

Replies are listed 'Best First'.
Re^4: Use of uninitialized value in join or string
by domaniqs (Initiate) on Jan 29, 2014 at 13:36 UTC

    Thank you hippo for pointing this out, however, the snippet I've inserted into my recent post, is the piece of code, that was removed and replaced by the code, that roboticus kindly suggested to me in his post.

    So instead of:

    my $SQL = "INSERT INTO $table VALUES (" . join(",", map { "?" } $csv->fields) . ")"; $prep = $db->prepare($SQL) or die "..."; while (my $row = $csv->getline($fh)) { $prep->execute($csv->fields); }

    I used:

    my $SQL = "INSERT INTO $table VALUES (" . join(",", map { "?" } $csv->fields) . ")"; $prep = $db->prepare($SQL) or die "Cannot prepare database"; while (my $row = $csv->getline($fh)) { $prep->execute($csv->fields); }

    It does not change the fact, that I still struggle with this new error:

    DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at ./ line 85, <$fh> line 2.

      Sorry, I misread your post. Your placeholders there look OK at first pass.

      So, for starters I would use @$row as the argument to execute and then I would compare the number of fields in $row with the number of fields in your database for $table and see where the mismatch occurs. HTH.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1072506]
[marto]: After Sunday I don't think I'll go see them again :)
[LanX]: Corion: come on, people are people! ;)
[Corion]: Naah, I think it's still an OK show so far. Their new songs aren't exactly great, but I'm not going there for new material anyway ;)
[marto]: I got the feeling from the last show that for big sections of it, they were not really into what they were doing
[Corion]: LanX: Sure, they can bask in my Halo
[marto]: more so than the previous show I saw
[Corion]: marto: Well, I think they go a tour every two years and I think it's hard to even get a connection with the crowd at a 20k people concert... But maybe after this time I'll stop too ;)
[Corion]: I still have to see the Pet Shop Boys live before they stop touring at all
[marto]: yeah, I think that as a group creatively they're done. I can understand how it'd be hard to stop the process, album/tour, album/tour, if that's pretty much all you've ever done :)
[marto]: Corion yes I saw them Pandemonium_Tour

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2017-03-24 11:39 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (301 votes). Check out past polls.