Hey everyone, quick question, can anyone help me turn this code into something I can use in the DBI class to create a database if a button on a form is clicked. I have managed to make the button work, but am having trouble combining these two codes, although, there may be another one i should use instead of "do"
This is the code i want to run off a form button:
CREATE DATABASE cag_repeat;
DROP TABLE cag_repeat.CAG_MAIN;
CREATE TABLE cag_repeat.CAG_MAIN
(
ID INT(10) NOT NULL auto_increment,
SEQUENCE_NAME VARCHAR(100) NOT NULL,
SEQUENCE TEXT NOT NULL,
NOREPEATS VARCHAR(100) NOT NULL,
LOCATION VARCHAR(100) NOT NULL,
WARNINGLVL VARCHAR(20) NOT NULL,
PRIMARY KEY (ID)
);
And this is what i believe could work, but i dont know the syntax to make it work:
(using this do command to actually run the code above, instead of using it like it is below to insert data into the database)
############################# Insert Into Database ###################
+##########
my $dbh = DBI->connect($dsn, $user, $password) or die "Unable to conne
+ct: $DBI::errstr\n";
my $row = $dbh->do("INSERT INTO cag_repeat.CAG_MAIN
(SEQUENCE_NAME,SEQUENCE,NOREPEATS,LOCATION,WARNINGLVL)
VALUES('$seqname','$sequence','$len','$amino_acid_number','$riskeval')
+;");
$dbh->disconnect();
######################################################################
+##########
Thank you for your help
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.