Thanks both of you for the quick replies.
The code for updating the database is shown below, jlongino: thanks for the pointer, I'm not much of an admin and it all looks to be set up the same. I'll keep on it though.
%hash: $ColName => $Value
The subroutine below is called with $page_url to tell it where to apply the update. The hash is global.
sub update_database { my($page_url)=@_; my(@categorys); my($category); my($dbfield); @categorys = keys(%hash); foreach $category (@categorys) { # Key is prefixed to match database $dbfield="Prefix".$category; # Establish database connection with MySQL my $dsn = 'DBI:mysql:*database*:localhost'; my $db_user_name = '*username*'; my $db_password = '*password*'; my $dbh = DBI->connect($dsn, $db_user_name, $db_password); my $sth = $dbh->prepare(qq{ update table set $dbfield = '$hash{$category}' where pageu +rl = '$page_url' }); $sth->execute(); $sth->finish(); } }
In reply to Re^3: Peculiar Behaviour with DBI and MySQL
by ChrisJ-UK
in thread Peculiar Behaviour with DBI and MySQL
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |