in reply to Re^2: Peculiar Behaviour with DBI and MySQL
in thread Peculiar Behaviour with DBI and MySQL
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(); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Peculiar Behaviour with DBI and MySQL
by gellyfish (Monsignor) on Jul 22, 2004 at 15:24 UTC | |
|
Re^4: Peculiar Behaviour with DBI and MySQL
by pbeckingham (Parson) on Jul 22, 2004 at 15:52 UTC | |
|
Re^4: Peculiar Behaviour with DBI and MySQL
by superfrink (Curate) on Jul 23, 2004 at 01:49 UTC |