Hello I am new to perl and was trying to load data from a text file on my hard drive and failing that, from a text file on the server, to a table in a database on the server, and neither worked.

It only worked when I went into PHPMyAdmin on the server, from a text file on my hard drive to the table, but I wanted to do it from the script as hereunder which was the script I tried to load data on a text file on the server to a table in the database. I did not receive any error notices when I brought the file up in the address and pressed enter and/or refresh. I knew it didn't work because when I refreshed the table there was no new data therein:-

#!/user/bin/perl use CGI::Carp qw(fatalsToBrowser); use DBI; print "Content-type:text/html\n\n"; #open connection to access database $dbh = DBI->connect("DBI:mysql:bgoddard_musicexperiences:localhost","",""); #prepare and execute SQL statement $sqlstatement="LOAD DATA LOCAL INFILE 'reas_orders.txt' INTO TABLE 're +as_orders' FIELDS TERMINATED BY '/' ESCAPED BY '\\' LINES TERMINATED BY '\r\n'"; $sth = $dbh->prepare($sqlstatement); $sth->execute or die "Could not execute SQL statement ... maybe invalid?"; $dbh->disconnect;

In reply to LOAD DATA LOCAL INFILE by brin

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.