为什么我的 Perl CGI 抱怨“无法找到 Mysql.pm”?
我有两个文件夹 php
和 perl
。它们分别包含 index.php
和 index.pl
。
我的 Perl 代码如下所示:
#!/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);
当我运行上面的代码时(通过在浏览器中输入 http://localhost:88/perl/
),我收到以下错误:
Can't located Mysql @INC 中的 .pm(@INC 包含:C:/xampp/perl/site/lib/ C:/xampp/perl/lib C:/xampp/perl/site/lib C:/xampp/apache)位于 C:/ xampp/htdocs/perl/index.pl 第 2 行。 BEGIN 失败 - 编译在 C:/xampp/htdocs/perl/index.pl 第 2 行中止。
浏览到 http://localhost: 88/php/ 有效。
index.php
有:
<?php
$con = mysql_connect("localhost","root","");
if($con)
{
if(mysql_select_db("cdcol", $con))
{
$sql="SELECT Id From products";
if(mysql_query($sql))
{
$result = mysql_query($sql);
if ($result) ...
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(mysql_select_db("cdcol", $con))
{
$sql="SELECT Id From products";
if(mysql_query($sql))
{
$result = mysql_query($sql);
if ($result) ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将 DBI 与 DBD::mysql。
您应该使用标准 CGI 处理模块,例如 CGI::Simple。
You should use DBI in conjunction with DBD::mysql.
You should use a standard CGI processing module such as CGI::Simple.