CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
DB Function Problem.

 



version2
New User

Feb 28, 2002, 6:40 AM

Post #1 of 3 (2354 views)
DB Function Problem. Can't Post

Hey all.

Can anyone tell me if they see anything wrong with this piece of code?


sub mark_paid{
my @pay_pals=split '', $FORM{ids};
foreach (@pay_pals){
$sql="update commissions set paid=1 where email='$_'";
$dbh->do($sql);}
}?>


This is supposed to set the paid field to 1 in a mysql database if a checkbox is checked on a form. However, it is not updating the database for some reason. I cant figure it out.


Paul
Enthusiast

Feb 28, 2002, 7:05 AM

Post #2 of 3 (2353 views)
Re: [version2] DB Function Problem. [In reply to] Can't Post

Use DBI->err and DBI->errstr to make sure it isn't a syntax error or something. Also print your query to make sure it looks right.


(This post was edited by RedRum on Feb 28, 2002, 7:08 AM)


mire
Novice

Mar 1, 2002, 8:18 PM

Post #3 of 3 (2338 views)
Re: [version2] DB Function Problem. [In reply to] Can't Post

Few things:
1) you're splitting on an empty string right ? That way you'll get all the letters in that array, not a good thing
2) you're not quoting your form data so your script is insecure.
3) log your code and you'll see you'll be able to solve problems yourself much often than now


_______________________________________________

Best regards,

Miroslav Madzarevic, Senior Perl Programmer
perl@modperldev.com
Mod Perl Development  - http://www.modperldev.com
Telephone: +381 64 1193 501
ICQ: 15880893
jamph

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives