If you're getting a 500 error, this tells me you are running this through a Web server. You're not sending any output back to the client, so your error log is probably complaining about "Premature end of script headers". That doesn't mean your program is wrong, just that you either need to run it from the command line or convert it to a proper CGI program. However, I wouldn't have a CGI program issuing "CREATE TABLE" commands :)

Assuming your shebang line is correct, here's a simple, complete CGI program:

#!/usr/local/bin/perl -wT use strict; use CGI qw/:standard/ print header, start_html( -title => 'Test program' ), h1( 'Hello world' ), end_html;

Update: Ack! I see a problem in your program:

my $table = $dbh->prepare qq' CREATE TABLE players (realname CHAR(20), = gold CHAR(40))');

Take a close look at your single quotes! It looks like you missed a parentheses.

my $table = $dbh->prepare( qq' CREATE TABLE players (realname CHAR(20), gold CHAR(40))');

Further, I'm already seeing some database design issues that you need to think about. Include a non-identifying ID for the player. If you use the realname as the ID, you can't easily update it.

create table players ( player_id INTEGER NOT NULL, firstname VARCHAR(15), lastlast VARCHAR(20), gold INTEGER );

Now, have every table that needs to link to the players table use the player_id. You can then change the other data at will.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid) Re: dbi 500 error by Ovid
in thread dbi 500 error by Anonymous Monk

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.