I have two folders php and perl. They contain index.php and index.pl, respectively.
My Perl code looks like:
#!/usr/bin/perl
use Mysql;
print "Content-type: text/html\n\n"; 
print "<h2>PERL-mySQL Connect</h2>";
print "page info";
$host = "localhost";
$database = "cdcol";
$user = "root";
$password = "";
$db = Mysql->connect($host, $database, $user, $password);
$db->selectdb($database);
When i run above code (by typing http://localhost:88/perl/ in the browser), I get the following error:
Can't locate Mysql.pm in @INC (@INC contains: C:/xampp/perl/site/lib/ C:/xampp/perl/lib C:/xampp/perl/site/lib C:/xampp/apache) at C:/xampp/htdocs/perl/index.pl line 2. BEGIN failed--compilation aborted at C:/xampp/htdocs/perl/index.pl line 2.
whereas browsing to http://localhost:88/php/ works.
index.php has:
<?php
$con = mysql_connect("localhost","root","");
    if($con)
    {
        if开发者_如何学Python(mysql_select_db("cdcol", $con))
        {
            $sql="SELECT Id From products";
            if(mysql_query($sql))
            {
                $result = mysql_query($sql);
                if ($result) ...
You should use DBI in conjunction with DBD::mysql.
You should use a standard CGI processing module such as CGI::Simple.
use strict; use warnings;
use CGI::Simple;
use DBI;
my $cgi = CGI::Simple->new;
my $dsn = sprintf(
    'DBI:mysql:database=%s;host=%s',
    'cdcol', 'localhost'
);
my $dbh = DBI->connect($dsn, root => '',
    { AutoCommit => 0, RaiseError => 0 }
);
my $status = $dbh ? 'Connected' : 'Failed to connect';
print $cgi->header, <<HTML;
<!DOCTYPE HTML>
<html>
<head><title>Test</title></head>
<body>
<h1>Perl CGI Script</h1>
<p>$status</p>
</body>
</html>
HTML
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论