1

I've just started learning perl. So i am getting introduced to database connectivity here. For this i am using XAMPP server installed on my windows7 machine. Following is a sample piece of code that i have written for testing database.

#!D:\xampp\perl\perl.exe
print " Enter Name : ";
chomp($name=<STDIN>);
print " Enter Age : ";
chomp($age=<STDIN>);

use DBI;

$dbh=DBI->connect('DBI:mysql:test');

$insert="insert into student values ('$name',$age)";
$d=$dbh->prepare($insert);
$d->execute();

$s="select * from student";
$s1=$dbh->prepare($s);
$s1->execute();

while(@v=$s1->fetchrow_array)
{
    print "$v[0] \t $v[1] \n";
}

$dbh->disconnect();

As you might be able to see that i'm using the test database available in the phpmyadmin database. i have created a student table with name and age as columns. But when i run this code in my browser i get the following error.

C:\Users\dellpc\Google Drive\coding\web>perl datab.pl
Enter Name : one Enter Age : 20 install_driver(mysql) failed: Can't load 'D:/xampp/perl/vendor/lib/auto/DBD/mysql/mysql.dll' for module DBD::mysql: load_file:The specified module could not be found at D:/xampp/perl/lib/DynaLoader.pm line 190, line 2. at (eval 4) line 3. Compilation failed in require at (eval 4) line 3, line 2. Perhaps a required shared library or dll isn't installed where expected at datab.pl line 9.

I browsed over Google to find out what this error could mean. It seemed that i was missing a file called libmysql.dll , which i downloaded and copied in the xampp perl/bin and the perl/vendor/.../DBD directory as well but this did not help.

I also tried using older version of XAMPP , the issue still persists. Does anyone has any idea how to fix this? Thanks in advance. :)

Edit 1:

This is the error i get when i try install commands.

> cpan> install DBI 

T/TI/TIMB/DBI-1.634.tar.gz Has already been unwrapped into directory D:\xampp\cpan\build\DBI-1.634-HZNMVR Could not make: Unknown error Running make test Can't test without successful make Running make install Make had returned bad status, install seems impossible

cpan> install DBD::mysql Running install for module 'DBD::mysql'

Running make for C/CA/CAPTTOFU/DBD-mysql-4.033.tar.gz Has already been unwrapped into directory D:\xampp\cpan\build\DBD-mysql-4.033-3pgMhg
'D:\xampp\perl\bin\perl.exe Makefile.PL' returned status 512, won't make Running make test Make had some problems, won't test Running make install Make had some problems, won't installRunning install for module 'DBI' Running make for

5
  • Does the file 'D:/xampp/perl/vendor/lib/auto/DBD/mysql/mysql.dll' exist? Have you installed DBD::mysql? If so, how did you install it? Commented Mar 10, 2016 at 13:05
  • This file was already there. prntscr.com/adhey3 Also i tried using the install command cpan> install DBI cpan> install DBD::mysql It also did not help. Commented Mar 10, 2016 at 13:47
  • Is that the right way to install i.e. using cpan for xampp or should i use something else? Commented Mar 10, 2016 at 14:13
  • Using "cpan" (or "cpanm") seems fine. But it seems that something isn't quite right here. I'm afraid I avoid Windows, so I can't be any more help. Commented Mar 10, 2016 at 14:16
  • I appreciate the help , thanks. Commented Mar 10, 2016 at 14:21

1 Answer 1

2

I found a workaround this:

It seems the xampp version of perl is somewhat not ready or has missing files. So i just installed strawberry Perl, and the program ran without any issue. I hope it helps any others who are looking for a fix.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.