JaimeJegonia
asked on
PERL INSTALLATION
I want to connect to mysql using Perl DBI with the following data and code. Oh, by the way I'm using xampp for linux. I've tried to save it on /opt/lampp/htdocs folder, compile it and run it on http://localhost/test.cgi no errors occured but it doesn't print anything except "duhh" on a blue background:-/. I can't connect to mysql...:-( why? Can anybody help me solve this problem?
By the way i failed to install DBD:mysql... An error message "can't find mysql.h" was displayed. I tried to locate it using "locate" i cant indeed find this file.. Where could I get this file? Is this related to my problem above?? (DBI installation was, on the other hand, successful)
database_name:adventure
user: root
password: sithas
host: localhost
tablename: participant
<------------------------- -----code- --test.cgi ---------- ---------- ---------- --->
#!/usr/bin/perl
use warnings;
use CGI::Pretty;
use strict;
use DBI();
my $cgi = new CGI;
print $cgi->header();
print $cgi->start_html(
-tilte=>'try',
-bgcolor=>'blue'
);
print "duhh!";
my $dbh = DBI->connect("DBI:mysql:da tabase=adv enture;hos t=localhos t","root", "sithas", {'RaiseError' => 1});
print "ad";
my $sth = $dbh->prepare("SELECT * FROM participant") or die "query failed";
$sth->execute();
print "sulod";
while (my $ref = $sth->fetchrow_hashref()) {
print "good";
}
$sth->finish();
$dbh->disconnect();
print $cgi->end_html();
<------------------------- ---------- --------en d--------- ---------- ---------- ---------- ----->
By the way i failed to install DBD:mysql... An error message "can't find mysql.h" was displayed. I tried to locate it using "locate" i cant indeed find this file.. Where could I get this file? Is this related to my problem above?? (DBI installation was, on the other hand, successful)
database_name:adventure
user: root
password: sithas
host: localhost
tablename: participant
<-------------------------
#!/usr/bin/perl
use warnings;
use CGI::Pretty;
use strict;
use DBI();
my $cgi = new CGI;
print $cgi->header();
print $cgi->start_html(
-tilte=>'try',
-bgcolor=>'blue'
);
print "duhh!";
my $dbh = DBI->connect("DBI:mysql:da
print "ad";
my $sth = $dbh->prepare("SELECT * FROM participant") or die "query failed";
$sth->execute();
print "sulod";
while (my $ref = $sth->fetchrow_hashref()) {
print "good";
}
$sth->finish();
$dbh->disconnect();
print $cgi->end_html();
<-------------------------
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What Unix/Linux version are you using?
Is mysql installed?
How did you try to install DBD::mysql?
Is mysql installed?
How did you try to install DBD::mysql?
ASKER
wlfs,
i've tried it, but the module is not available on CPAN
"The module DBD::mysql isn't available on CPAN"
I also tried to download and installed DBD:: mysql but there was an error "mysql.h could not be found"
FishMonger,
i try to ran this commands but an error occurred "syntax error at -e line 1, near " }) ", execution of -e aborted"
i've tried it, but the module is not available on CPAN
"The module DBD::mysql isn't available on CPAN"
I also tried to download and installed DBD:: mysql but there was an error "mysql.h could not be found"
FishMonger,
i try to ran this commands but an error occurred "syntax error at -e line 1, near " }) ", execution of -e aborted"
ASKER
Tintin,
I'm using Ubunto.
i've downloaded DBD-mysql-2.9004 and then extracted it. but when i try to run "perl Makefile.PL" error ocurred "mysql.h could not be found
what could be the solution for this? please help. thanks!
I'm using Ubunto.
i've downloaded DBD-mysql-2.9004 and then extracted it. but when i try to run "perl Makefile.PL" error ocurred "mysql.h could not be found
what could be the solution for this? please help. thanks!
Mixing up the names... :)
Did you copy-paste the one-liner? There is no syntax error in as far as my perl is concerned :)
This is a "screenshot" of my command line:
sandbox$ perl -MDBI -we 'DBI->connect("DBI:mysql:d atabase=ad venture;ho st=localho st","root" ,"sithas", {RaiseError => 1}) or die($DBI::errstr);'
DBI connect('database=adventur e;host=loc alhost','r oot',...) failed: Access denied for user: 'root@localhost' (Using password: YES) at -e line 1
Did you copy-paste the one-liner? There is no syntax error in as far as my perl is concerned :)
This is a "screenshot" of my command line:
sandbox$ perl -MDBI -we 'DBI->connect("DBI:mysql:d
DBI connect('database=adventur
What mysql packages do you have installed?
ASKER
xampp for linux was the mysql package i used
>> "The module DBD::mysql isn't available on CPAN"
Wrong...it is available on cpan.
[root@perlman ~]# perl -MCPAN -e 'install DBD::mysql'
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Database was generated on Sat, 15 Apr 2006 11:46:26 GMT
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/authors/01mailrc.txt.gz
Going to read /root/.cpan/sources/author s/01mailrc .txt.gz
CPAN: Compress::Zlib loaded ok
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/modules/02packages.details.txt.gz
Going to read /root/.cpan/sources/module s/02packag es.details .txt.gz
Database was generated on Wed, 03 May 2006 23:30:52 GMT
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/modules/03modlist.data.gz
Going to read /root/.cpan/sources/module s/03modlis t.data.gz
Going to write /root/.cpan/Metadata
Running install for module DBD::mysql
Running make for C/CA/CAPTTOFU/DBD-mysql-3. 0002.tar.g z
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-3.0002.tar.gz
CPAN: Digest::SHA loaded ok
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/authors/id/C/CA/CAPTTOFU/CHECKSUMS
CPAN: Module::Signature loaded ok
WARNING: This key is not certified with a trusted signature!
Primary key fingerprint: 2E66 557A B97C 19C7 91AF 8E20 328D A867 450F 89EC
Signature for /root/.cpan/sources/author s/id/C/CA/ CAPTTOFU/C HECKSUMS ok
Checksum for /root/.cpan/sources/author s/id/C/CA/ CAPTTOFU/D BD-mysql-3 .0002.tar. gz ok
Scanning cache /root/.cpan/build for sizes
DBD-mysql-3.0002/
DBD-mysql-3.0002/ChangeLog
DBD-mysql-3.0002/constants .h
DBD-mysql-3.0002/dbdimp.c
DBD-mysql-3.0002/dbdimp.h
Wrong...it is available on cpan.
[root@perlman ~]# perl -MCPAN -e 'install DBD::mysql'
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Database was generated on Sat, 15 Apr 2006 11:46:26 GMT
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/authors/01mailrc.txt.gz
Going to read /root/.cpan/sources/author
CPAN: Compress::Zlib loaded ok
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/modules/02packages.details.txt.gz
Going to read /root/.cpan/sources/module
Database was generated on Wed, 03 May 2006 23:30:52 GMT
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/modules/03modlist.data.gz
Going to read /root/.cpan/sources/module
Going to write /root/.cpan/Metadata
Running install for module DBD::mysql
Running make for C/CA/CAPTTOFU/DBD-mysql-3.
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-3.0002.tar.gz
CPAN: Digest::SHA loaded ok
Fetching with LWP:
ftp://cpan-sj.viaverio.com/pub/CPAN/authors/id/C/CA/CAPTTOFU/CHECKSUMS
CPAN: Module::Signature loaded ok
WARNING: This key is not certified with a trusted signature!
Primary key fingerprint: 2E66 557A B97C 19C7 91AF 8E20 328D A867 450F 89EC
Signature for /root/.cpan/sources/author
Checksum for /root/.cpan/sources/author
Scanning cache /root/.cpan/build for sizes
DBD-mysql-3.0002/
DBD-mysql-3.0002/ChangeLog
DBD-mysql-3.0002/constants
DBD-mysql-3.0002/dbdimp.c
DBD-mysql-3.0002/dbdimp.h
ASKER
wlfs, yes i copied and pasted the one liner but it doesn't work for me...
Hmm, weird. Don't know which OS you are using. Maybe you have to try different quoting for the shell. Try:
perl -MDBI -we "DBI->connect(qq(DBI:mysql :database= adventure; host=local host),qq(r oot),qq(si thas), {RaiseError => 1}) or die($DBI::errstr);"
or
perl -MDBI -we 'DBI->connect(qq(DBI:mysql :database= adventure; host=local host),qq(r oot),qq(si thas), {RaiseError => 1}) or die($DBI::errstr);'
perl -MDBI -we "DBI->connect(qq(DBI:mysql
or
perl -MDBI -we 'DBI->connect(qq(DBI:mysql
>> i copied and pasted the one liner but it doesn't work for me...
What does "doesn't work for me..." mean?
What error message did you get?
Were you able to get the DBD::mysql module installed? If you don't have the databse driver for Perl to use, you won't be able to connect to the database.
What does "doesn't work for me..." mean?
What error message did you get?
Were you able to get the DBD::mysql module installed? If you don't have the databse driver for Perl to use, you won't be able to connect to the database.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
linux is cumbersome i really can't install DBD:mysql... i just switch to windows using ActivePerl but thanks for all the help i really appreciate it!
from the command line:
perl -MCPAN -e 'install DBD::mysql'