June 24th, 2000, 03:47 AM
Join Date: Jun 2000
Time spent in forums: < 1 sec
Reputation Power: 0
I wrote a few days ago asking for help with inserting data into mysql with perl. Thanks to all who offered their help. I really am trying to learn perl, but I'm not a natural by any stretch. I am able to get the information in the database, but I know their is a much simpler way with loops. I've learned so much in the last two weeks, but not enough to slim this down. Here's the script that works, but is very lengthy:
#get the parameter from the html form.
# goes on for years
$sql="INSERT INTO main(name,address,city,state,zip...) values('$name','$address','$city','$state','$zip'...)";
# I know about the quote thingy, but how do I simplify the stuff before values?
$sth = $dbh->prepare($sql)
or die "Can't prepare $sql: $dbh->errstrn";
$rv = $sth->execute
or die "can't execute the query: $sth->errstrn";
print "Record has been successfully updated !!!n";
print "Error!!while inserting recordn";
This is trimmed way down from the 21 variables in the script. I've been reading and studying other scripts. I just can't do it. My mind is fried from trying to figure this simple thing out. I will keep on studying. Any pointers appreciated. To lessen the length of this post, my email is firstname.lastname@example.org. Thanks.