Dear Monks
Greetings
I am learning CGI with MySQL connection. I am using following CGI script, which I got from some tutorial
#!/usr/bin/perl -wT print "Content-type: text/html \n\n"; use DBI; # Connect To Database $database = "a_qtest"; $username = "a_read"; $password = "password"; $hostname = "localhost"; $db = DBI->connect("DBI:mysql:$database:$hostname", $username, $passwo +rd); if(!$db = DBI->connect("DBI:mysql:$database:$hostname", $username, $pa +ssword)) print "Connection unsuccessful. Please check your login credentia +ls. ".$DBI::errstr; # Execute a Query $query = $db->prepare("SELECT * FROM mytable"); $query->execute; # How many rows in result? $numrows = $query->rows; # Display Results while (@array = $query->fetchrow_array) { ($field1, $field2, $field3) = @array; print "field1 = $field1, field2 = $field2, field3 = $field3 "; } # Cleaning Up $query->finish; $db->disconnect; exit(0);
I am getting following error
Internal Server Error The server encountered an internal error or misconfiguration and was u +nable to complete your request. Please contact the server administrator, webmaster@myurl.com and infor +m them of the time the error occurred, and anything you might have do +ne that may have caused the error. More information about this error may be available in the server error + log. Additionally, a 404 Not Found error was encountered while trying to us +e an ErrorDocument to handle the request. ---------------------------------------------------------------------- +---------- Apache/2.2.13 Server at www.myurl.com Port 80
I would be grateful if anyone provides me any clues.
Regards,
SanPerl

In reply to Basic error in CGI script by sanPerl

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.