Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^7: Why is my code assigning the last-retrieved value to all elements in my hash?

by punch_card_don (Curate)
on Jul 09, 2008 at 21:02 UTC ( [id://696564]=note: print w/replies, xml ) Need Help??


in reply to Re^6: Why is my code assigning the last-retrieved value to all elements in my hash?
in thread Why is my code assigning the last-retrieved value to all elements in my hash?

So here's the truly bizarre part: Changing the hash populating routine to this
$sql = "SELECT book_id, title FROM booklist_table WHERE (expected_publ +cn_date >= '".$start_date."' AND expected_publcn_date <= '".$end_date +."')"; $sth = $dbh->prepare($sql) or die("Could not prepare!" . $dbh->errstr) +; $sth->execute() or die("Could not execute!" . $dbh->errstr); while (($book_id, $title) = $sth->fetchrow_array()) { $booklist_1{$book_id} = $title; } $sth->finish;
makes it all work perfectly.

Changing just one line of the above code to

$booklist_1{$book_id} = "ok";
makes it revert to the original incorrect behaviour.



Time flies like an arrow. Fruit flies like a banana.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://696564]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-19 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found