
davorg
Thaumaturge
/ Moderator
Feb 18, 2005, 2:31 AM
Post #2 of 2
(296 views)
|
|
Re: [spike4000] Won't write to database
[In reply to]
|
Can't Post
|
|
When I press "save", it doesn't save to the database (Oracle)? What's wrong below? my $p1 = param('col1'); my $dbh1 = DBI->connect("DBI:Oracle:$sid", "$dbuser", "$pw",{AutoCommit=>1}); ($p2, $p3, $p4) = $dbh1->selectrow_array("SELECT col2, col3, col4 FROM table WHERE col1 = '$p1'"); print "Edit"; print "<form method=\"post\" action=\"e2.pl\">"; print "P3:<input type=text value=\"$p3\" name=p3>"; print "P4:<input type=text value=\"$p4\" name=p4>"; print "<input type=submit name=edit value='SAVE CHANGES'>"; print "</form>"; my $dbh = DBI->connect("DBI:Oracle:$sid", "$dbuser", "$dbpw",{AutoCommit=>1}); my $sth = $dbh->prepare("UPDATE table SET col3='$p3', col4='$p4' WHERE col1 = '$p1'"); $sth->execute; In my experience, with Oracle the hardest part is getting everything set up correctly so you can connect to the database :) You don't check that either of your connections are successful. Maybe you're not connecting to the DB at all. Are you getting any errors in the web server error log? -- Dave Cross, Perl Hacker, Trainer and Writer http://www.dave.org.uk/ Get more help at Perl Monks
|