Any changes of httpd.conf that I shall do? Or in any other configuration
file? Or...?
DBIcreatetable doesn't run but printenv does:

DBIcreatetable:
"
#!C:\Dwimperl\perl\bin\perl.exe
use 5.010;
use strict;
use warnings;

use DBI;

print "Content-type: text/plain; charset=iso-8859-1\n\n";
say "Perl MySQL Create Table Demo";

# MySQL database configurations
my $dsn = "DBI:mysql:clients";
my $username = "root";
my $password = "pw";

# connect to MySQL database
my %attr = (PrintError=>0, RaiseError=>1);

my $dbh = DBI->connect($dsn,$username,$password, \%attr);

# create table statements
my @ddl =     (
 # create tags table
 "CREATE TABLE tags (
 tag_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 tag varchar(255) NOT NULL
         ) ENGINE=InnoDB;",
        # create links table
        "CREATE TABLE links (
   link_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
   title varchar(255) NOT NULL,
   url varchar(255) NOT NULL,
   target varchar(45) NOT NULL
 ) ENGINE=InnoDB;",
 # create link_tags table
 "CREATE TABLE link_tags (
   link_id int(11) NOT NULL,
   tag_id int(11) NOT NULL,
   PRIMARY KEY (link_id,tag_id),
   KEY fk_link_idx (link_id),
   KEY fk_tag_idx (tag_id),
   CONSTRAINT fk_tag FOREIGN KEY (tag_id)
      REFERENCES tags (tag_id),
   CONSTRAINT fk_link FOREIGN KEY (link_id)
 REFERENCES links (link_id)
 ) ENGINE=InnoDB"
        );

# execute all create table statements
for my $sql(@ddl){
  $dbh->do($sql);
}

say "All tables created successfully!";

# disconnect from the MySQL database
$dbh->disconnect();
"
printenv:
"
#!C:\Dwimperl\perl\bin\perl.exe
#

# To permit this cgi, replace # on the first line above with the
# appropriate #!/path/to/perl shebang, and on Unix / Linux also
# set this script executable with chmod 755.
#
# ***** !!! WARNING !!! *****
# This script echoes the server environment variables and therefore
# leaks information - so NEVER use it in a live server environment!
# It is provided only for testing purpose.
# Also note that it is subject to cross site scripting attacks on
# MS IE and any other browser which fails to honor RFC2616.

##
##  printenv -- demo CGI program which just prints its environment
##
use strict;
use warnings;

print "Content-type: text/plain; charset=iso-8859-1\n\n";
foreach my $var (sort(keys(%ENV))) {
    my $val = $ENV{$var};
    $val =~ s|\n|\\n|g;
    $val =~ s|"|\\"|g;
    print "${var}=\"${val}\"\n";
}
"

Reply via email to