June 24th, 2000, 03:47 AM
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 email@example.com. Thanks.
June 24th, 2000, 07:13 AM
but not enough to slim this down. Here's the script that works, but is very lengthy:
You can optimize a script in different ways.
Probably you can write a subroutine and pass your queries to it.That subroutine will process the query and give you the result.so you can use that subroutine through out the project for database manipulation.
First learn perl very well .then you will be getting a very good understanding about what you want to do...
"The fear of the LORD is the beginning of knowledge..."