Jonas has asked for the wisdom of the Perl Monks concerning the following question:
Hey folks,
I'm using a hash, %user_info, to make an update to a a database I've built. I have already connected to the database just fine.
I get the error:$sth = $dbh->prepare(" Update tUser Set ? = ? Where UserId = $user_info{UserId} "); foreach $key(keys %user_info) { if ($key ne "UserId") { $sth->execute($key, $user_info{$key}); } } $sth->finish();
I'm positive that it's because the field is in quotes. Is there a better way to do this, or is there a command to take the quotes away?DBD::mysql::st execute failed: You have an error in your SQL syntax ne +ar ''LastName' = 'Smith' Where UserId = 1 ' at line 2 at /usr/usr_update line 197.
Thanks in advance,
t
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: DB Update w/ Hash
by athomason (Curate) on Sep 05, 2000 at 05:53 UTC | |
by Anonymous Monk on Sep 06, 2000 at 14:54 UTC | |
by davorg (Chancellor) on Sep 06, 2000 at 15:13 UTC | |
by Jonas (Beadle) on Sep 05, 2000 at 06:04 UTC | |
Re: DB Update w/ Hash
by ferrency (Deacon) on Sep 05, 2000 at 19:53 UTC | |
Re: DB Update w/ Hash
by agoth (Chaplain) on Sep 05, 2000 at 13:01 UTC | |
Re: DB Update w/ Hash
by Jonas (Beadle) on Sep 05, 2000 at 06:32 UTC |
Back to
Seekers of Perl Wisdom