#!c:\perl64\bin\perl use DBD::Mysql; use DBI; print "Content-type: text/html \n\n"; $host = "localhost"; $database="test555"; $tablename1="t6"; $tablename2 ="table123"; $tablename3="test77"; $user = "root"; $pw = "root"; $connect = DBI->connect($host, $database, $user, $pw); $connect->selectdb($database); $myquery = "INSERT INTO $tablename3 (testcolumn) VALUES ('try')"; $execute = $connect->query($myquery); $affectedrows = $execute->affectedrows($myquery); $lastid = $execute->insertid($myquery); print $affectedrows."<br />"; print $lastid."<br />";
Unable to execute the perl code. **Output message:** *c:\mani\Perl_Scripts>perl mysql_test.pl Content-type: text/html DBI->connect using 'old-style' syntax is deprecated and will be an error in futu re versions at mysql_test.pl line 18 install_driver(root) failed: Can't locate DBD/root.pm in @INC (@INC contains: C: /Perl64/site/lib C:/Perl64/lib .) at (eval 5) line 3. Perhaps the DBD::root perl module hasn't been fully installed, or perhaps the capitalisation of 'root' isn't right. Available drivers: CSV, DBM, ExampleP, File, Gofer, LDAP, Mock, ODBC, Oracle, Pg , Proxy, SQLite, Sponge, Wire10, mysql, mysqlPP. at mysql_test.pl line 18* I have installed DBD- MySQL package and I am not sure of DBI package, whether I installed through ppm. I am attaching a screenshot of all the installed packages related to MySQL. I even searched for MySQL ODBC package, as an alternative, as suggested by a friend. But, couldn't find for **ActivePerl**. I am using ActivePerl in my system. I intially used, command, *use mysql*; *MYSQL->CONNECT($host, $database, $user, $pw);* FOR WHICH I GOT THE MESSAGE INITIALLY, PERL.PM NOT FOUND. i PLACED THE PERL.PM FILE INTO THE PATH AND THEN, I GOT THE MESSAGE, CONNECTION DOESN'T EXIST FOR MYSQL PACKAGE. So, can you please tell the probable area, where I have missed and any related coding issues? Thanks, Mani

Original content restored above by GrandFather. Update follows:

#!C:\perl64\bin\perl.exe -wT use strict; use warnings; use DBI; print "Content-type: text/html \n\n"; # MYSQL CONFIG VARIABLES my $driver = "mysql"; my $database="test555"; my $tablename3="test77"; my $user = "root"; my $pw = "root"; # PERL MYSQL CONNECT() my $dbh = DBI->connect("DBI:$driver:$database", $user, $pw, ) ; my $sth = $dbh->prepare(" SELECT * FROM t6 WHERE paragraph='PQX03904' ") ; $sth->execute() ; #$dbh->disconnect; #exit 0;
When I give $dbh->disconnect, the last before line, system is throwing up error When I comment that, the system is not throwing up any error, neither output. Please help!

In reply to ActivePerl for MySQL queries in windows7 by mani87

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.