473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

trying to connect to DB

35
i've been trying to connect to a db using this code:
Expand|Select|Wrap|Line Numbers
  1. #!"C:\xampp\perl\strawberry\perl\bin\perl.exe"
  2. use DBI;
  3.  use strict;
  4.  use warnings;
  5.  
  6. print "Content-type: text/html \n\n"; #HTTP HEADER
  7. my $dbh = DBI->connect("DBI:mysql:survey","root","") or die "Couldn't connect to database: " . DBI->errstr;
but it does not work, i dont get the die error message only this default xampp error :
Server error!

The server encountered an internal error and was unable to complete your request.

Error message:
Expand|Select|Wrap|Line Numbers
  1. Premature end of script headers: DB.pl
  2.  
  3. If you think this is a server error, please contact the webmaster.
  4. Error 500
  5. localhost
  6. 12/06/09 11:00:53
  7. Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.8 
Dec 6 '09 #1
11 4297
RonB
589 Expert Mod 512MB
Did you check the apache error log?

It's probably due to your shebang line. Try changing it to this:
Expand|Select|Wrap|Line Numbers
  1. #!C:/xampp/perl/strawberry/perl/bin/perl.exe
Dec 6 '09 #2
numberwhun
3,509 Expert Mod 2GB
Unfortunately, I don't have any experience with xampp, so I am not aware of the caveats.

I guess my first question is, can you connect to the database manually from the command line? If not, what does it tell you?

Regards,

Jeff
Dec 6 '09 #3
RonB
589 Expert Mod 512MB
I just noticed that you have a syntax error in the error handling portion of the connect statement.
Expand|Select|Wrap|Line Numbers
  1. DBI->errstr
should be
Expand|Select|Wrap|Line Numbers
  1. $DBI::errstr
Try this version:
Expand|Select|Wrap|Line Numbers
  1. #!C:/xampp/perl/strawberry/perl/bin/perl.exe
  2.  
  3. use strict;
  4. use warnings;
  5. use DBI;
  6. use CGI qw(:standard);
  7. use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
  8.  
  9. print header();
  10. warningsToBrowser(1);
  11.  
  12. my $dbh = DBI->connect("DBI:mysql:survey", "root", "", { RaiseError => 1 } )
  13.                or die "Couldn't connect to database: " . $DBI::errstr;
  14.  
  15. print start_html(),
  16.       h1("It worked");
  17.  
  18. print end_html();
Dec 6 '09 #4
arty
35
nothing works , i get this from apache log:
Expand|Select|Wrap|Line Numbers
  1. [Sun Dec 06 20:06:56 2009] [error] [client 127.0.0.1] Can't locate DBI.pm in @INC (@INC contains: C:/xampp/perl/strawberry/perl/lib C:/xampp/perl/strawberry/perl/site/lib C:\\strawberry\\perl\\vendor\\lib .) at C:/xampp/cgi-bin/DB.pl line 4.\r
  2. [Sun Dec 06 20:06:56 2009] [error] [client 127.0.0.1] BEGIN failed--compilation aborted at C:/xampp/cgi-bin/DB.pl line 4.\r
so it looks like it cant find DBI library but the library is there, I got perl strawberry.
Dec 6 '09 #5
RonB
589 Expert Mod 512MB
If DBI is on your system then based on the paths, I'd say that something wasn't installed properly, or you specified alternate directories during one of the installations and now you have a mix-match (conflict) in the directory structure.

Or, you have 2 separate installations of Perl (xampp and strawberry), which based on those paths is very likely.
Dec 6 '09 #6
arty
35
xampp comes with perl/bin/perl.exe, wich i heard in some kind of mini perl.
when you install strawberry you cant choose directory installation it will install by default in C/program files. So i just changed it of directory and place it in xampp/perl
Dec 7 '09 #7
RonB
589 Expert Mod 512MB
That's the cause of your problem. Install one or the other, not both.

I don't like xampp because it leaves out a lot of standard modules, forcing you to install them yourself.

My only objection to strawberry is the limitation in its choice of installation locations. Last time I checked you had absolutely no control over its install location.

My preference is to use ActivePerl http://www.activestate.com/activeperl/ and install each of the other items (mysql and apache) separately. This give you the most flexibility.

So, my recommendation is to uninstall xampp and strawberry Perl and start over.
Dec 7 '09 #8
numberwhun
3,509 Expert Mod 2GB
Personally, I prefer Strawberry Perl over Active State as AS has such a proprietory module installation system and does not allow you to install any cpan module.

I do agree with uninstalling xampp and SP and installing only one of them. Two Perls on one system is never good.

Regards,

Jeff
Dec 7 '09 #9
RonB
589 Expert Mod 512MB
Personally, I prefer Strawberry Perl over Active State as AS has such a proprietory module installation system and does not allow you to install any cpan module.
Actually, that's not true. The only thing missing from AS in their base install is the MinGW module (which is in AS's repository). MinGW installs the required compiler and configures CPAN.pm. I use AS's ppm utility for most of my installations, but I can and sometimes do install via cpan.

On the flip side, when using Strawberry Perl, you can install the ppm utility via cpan and have the choice of either cpan or ppm.
Dec 7 '09 #10
arty
35
i have never installed this mini perl version that's included with xampp , it is install ed by default and it just consist of a bin directory with inside a perl.exe file so i dont see how this could be affecting anything, btw if i uninstall xampp i would need to install php, apache, mysql, perl, phpmydamin etc .. separately but i 've never done this and looks like overkill right now , any tutorials on this ?
thanks
Dec 7 '09 #11
RonB
589 Expert Mod 512MB
A simple google search will provide numerous tutorials.

Here's one:
http://www.ricocheting.com/server/
Dec 7 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Subra Mallampalli | last post by:
Hi, I am trying to connect over HTTPS using a client certificate. I am able to connect fine when using IE. From my application, however, I get the following error: The underlying connection...
1
by: pemigh | last post by:
I'm almost done with an application, and trying to lock it down tightly. But I still want users to be able to point to a new location for the data file. The code below fires off to detect and...
5
by: kkddrpg | last post by:
the database looks like this the database is called username_tpp (not really just using username as a sub) the table is called home it has field 1 : varchar(50) | latin1_swedish_ci | no...
0
by: Marty | last post by:
As said in the title I am trying to connect to a .WK1 file. Here is my code so far: If (.ShowDialog() = Windows.Forms.DialogResult.OK) Then strFilePath =...
8
by: Newbie19 | last post by:
I am trying to connect to a SQL DB and I have owner access, but I am unable to connect. Here is my connectionstring: Dim connectionString As String = _ "Data...
5
by: Alan Silver | last post by:
Hello, Server configuration: Windows 2003 Server SP2 SQL Server 2000 SP4 ..NET v2.0.50727 just built up a new server using the same configuration as my current one. I even used the same CDs...
11
by: =?Utf-8?B?c2NodXJzdDMw?= | last post by:
Hi, I am currently trying to get back into ASP and have begun looking at an old webpage I developed some years ago, it was fully functional back in 2002 and I had it up and running with no...
1
by: danfolkes | last post by:
Hey Everyone, I am trying to send repeated messages from a "Node" to a "Server". It works the first time I send the from the Node to Server, but after that it either errors, or does not do...
6
by: SRK | last post by:
Hi, I have installed free TDS ODBC driver on Linux and from there I am trying to connect to MS SQLSERVER installed on Windows machine. But it gives me following error - tsql -H ps6312 -p 1433...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.