Re: Connection to MySQL DB fails when mod_perl enabled...
Hi there, On Tue, 22 May 2001, Ask Bjoern Hansen wrote: > If you want to die then Come on, mod_perl is tricky sometimes but things can't be that bad... 73, Ged.
RE: Connection to MySQL DB fails when mod_perl enabled...
At 03:28 AM 2001/5/22 +0100, you wrote: >Incidentally, I am using the following module versions: > >DBD-MySQL [1.2214]; >DBI [1.13] > >Does this have any bearing on my problem? Does reinstalling the DBI help? I had problem with DBI before. I just reinstalled it and it works fine. (I can just ignore everything and reinstall it because it's just my test server...) I didn't check what caused the problem tho. Bird
Re: Connection to MySQL DB fails when mod_perl enabled...
My Lords, Ladies and Gentlemen, I am delighted to announce that this problem is now SOLVED. That is, I can now access my MySQL database from a Perl script running under mod_perl. I won't detail the whole sorry affair again, but the rogue line read: $dsn = "DBI:$driver:database=shapeshifter;host=localhost"; I must offer special thanks to Guido Moonen [[EMAIL PROTECTED]] who suggested "In the error log is a error code 10061 (Which stands for connection refused) this means that the application cannot even open a connection to the mysql server. Maybe you should also provide the DSN with a port number. Or try to use 127.0.0.1 instead of localhost." I did try changing "localhost" to 127.0.0.1 (and also tried the actual IP address of the computer). This generated a whole new set of error messages that finally showed me the light. Two things were wrong: 1) I was using "localhost" when I should have been using an IP address 2) (you're not going to believe this) My firewall was dropping all requests between mod_perl (running on my machine) and the MySQL server (on my LAN) - yet it was allowing the same request using CGI rather than mod_perl, we're still trying to figure out why I adjusted both and got the output I have spent 36 hours seeking. I would like to thank every single person who took the time to offer their invaluable advice and help. I would also like to apologise for the huge volume of traffic this problem generated within the list. I'm sorry. Thanks again Guido. Kindest regards, Jonathan M. Hollin Digital-Word.com
Re: Connection to MySQL DB fails when mod_perl enabled...
My Lords, Ladies and Gentlemen, I am delighted to announce that this problem is now SOLVED. That is, I can now access my MySQL database from a Perl script running under mod_perl. I won't detail the whole sorry affair again, but the rogue line read: $dsn = "DBI:$driver:database=shapeshifter;host=localhost"; I must offer special thanks to Guido Moonen [[EMAIL PROTECTED]] who suggested "In the error log is a error code 10061 (Which stands for connection refused) this means that the application cannot even open a connection to the mysql server. Maybe you should also provide the DSN with a port number. Or try to use 127.0.0.1 instead of localhost." I did try changing "localhost" to 127.0.0.1 (and also tried the actual IP address of the computer). This generated a whole new set of error messages that finally showed me the light. Two things were wrong: 1) I was using "localhost" when I should have been using an IP address 2) (you're not going to believe this) My firewall was dropping all requests between mod_perl (running on my machine) and the MySQL server (on my LAN) - yet it was allowing the same request using CGI rather than mod_perl, we're still trying to figure out why I adjusted both and got the output I have spent 36 hours seeking. I would like to thank every single person who took the time to offer their invaluable advice and help. I would also like to apologise for the huge volume of traffic this problem generated within the list. I'm sorry. Thanks again Guido. Kindest regards, Jonathan M. Hollin Digital-Word.com
Re: Connection to MySQL DB fails when mod_perl enabled...
On Mon, 21 May 2001, Rodney Broom wrote: > $dbh = DBI->connect($dsn, dbusrname, dbpassword) > or die "Error: $DBI::errstr"; If you want to die then $dbh = DBI->connect($dsn, dbusrname, dbpassword, { RaiseError => 1}); would look neater. s/Raise/Print/ to just have it spew the error messages to the log without having to put 'or warn "..."' after every other line. - ask -- ask bjoern hansen, http://ask.netcetera.dk/ !try; do(); more than 100M impressions per day, http://valueclick.com
Re: Connection to MySQL DB fails when mod_perl enabled...
On Tue, 22 May 2001, Jonathan M. Hollin wrote: > This is driving me crazy... is there anything special I need to do when > using DBI (DBD::MySQL) with mod_perl. A script that works just fine sans > mod_perl dies with error 500 (Internal Server Error) when mod_perl is > enabled for that file type: [snip] One thing nobody seems to have suggested is enabling trace mode. Add in: DBI->trace(2); after "use DBI;". You'll get *lots* of stuff in your error log, but it might help track down the issue. (also this may sound dumb, but are you certain mysql is running when you try the tests - try connecting to the mysql TCP/IP port using "telnet localhost " (I don't know what the specific port is for MySQL, you'll have to read the docs). -- /||** Founder and CTO ** ** http://axkit.com/ ** //||** AxKit.com Ltd ** ** XML Application Serving ** // ||** http://axkit.org ** ** XSLT, XPathScript, XSP ** // \\| // ** mod_perl news and resources: http://take23.org ** \\// //\\ // \\
Re: Connection to MySQL DB fails when mod_perl enabled...
Ken Williams wrote: > [EMAIL PROTECTED] (Jonathan M. Hollin) wrote: > >:: Okay, last idea: you say you can connect to mysql from the command line, > >:: from regular CGI, and from PHP. I'm guessing that in all of those > >:: situations, you're acting as the same user (win2k user, not mysql user). > >:: However, under mod_perl you'll be acting as whatever user your web > >:: server runs as. That's probably the only real difference between > >:: mod_perl and the other situations. > >:: > >:: So if you can become that user and try connecting to the database, > >:: perhaps you can get more insight into the problem. > > > >I would like to try that (anything to get this working). Er... how do I do > >that? > > Under win2k, I have no idea. Under unix, you'd use "su" or a similar > identity-switching mechanism. You'll probably have to find a win2k > person to help with that. > > Let me also gently suggest that you should take this off-list, as there > have been a lot of messages on your topic already. But please post your resolution as it may be useful to someone else down the road. > > > ------ > Ken Williams Last Bastion of Euclidity > [EMAIL PROTECTED]The Math Forum
RE: Connection to MySQL DB fails when mod_perl enabled...
[EMAIL PROTECTED] (Jonathan M. Hollin) wrote: >:: Okay, last idea: you say you can connect to mysql from the command line, >:: from regular CGI, and from PHP. I'm guessing that in all of those >:: situations, you're acting as the same user (win2k user, not mysql user). >:: However, under mod_perl you'll be acting as whatever user your web >:: server runs as. That's probably the only real difference between >:: mod_perl and the other situations. >:: >:: So if you can become that user and try connecting to the database, >:: perhaps you can get more insight into the problem. > >I would like to try that (anything to get this working). Er... how do I do >that? Under win2k, I have no idea. Under unix, you'd use "su" or a similar identity-switching mechanism. You'll probably have to find a win2k person to help with that. Let me also gently suggest that you should take this off-list, as there have been a lot of messages on your topic already. ------ Ken Williams Last Bastion of Euclidity [EMAIL PROTECTED]The Math Forum
RE: Connection to MySQL DB fails when mod_perl enabled...
:: Okay, last idea: you say you can connect to mysql from the command line, :: from regular CGI, and from PHP. I'm guessing that in all of those :: situations, you're acting as the same user (win2k user, not mysql user). :: However, under mod_perl you'll be acting as whatever user your web :: server runs as. That's probably the only real difference between :: mod_perl and the other situations. :: :: So if you can become that user and try connecting to the database, :: perhaps you can get more insight into the problem. I would like to try that (anything to get this working). Er... how do I do that? Kindest regards, Jonathan M. Hollin Digital-Word.com
RE: Connection to MySQL DB fails when mod_perl enabled...
[EMAIL PROTECTED] (Jonathan M. Hollin) wrote: >I'm probably going to have to forfeit mod_perl after all. :-( Okay, last idea: you say you can connect to mysql from the command line, from regular CGI, and from PHP. I'm guessing that in all of those situations, you're acting as the same user (win2k user, not mysql user). However, under mod_perl you'll be acting as whatever user your web server runs as. That's probably the only real difference between mod_perl and the other situations. So if you can become that user and try connecting to the database, perhaps you can get more insight into the problem. ------ Ken Williams Last Bastion of Euclidity [EMAIL PROTECTED]The Math Forum
RE: Connection to MySQL DB fails when mod_perl enabled...
Incidentally, I am using the following module versions: DBD-MySQL [1.2214]; DBI [1.13] Does this have any bearing on my problem? Kindest regards, Jonathan M. Hollin Digital-Word.com LATEST NEWS: Digital-Word.com releases e-gateway v3.0. See: http://e-gateway.1-1IT.Net/ for further details... IMPORTANT: This e-mail and the information that it contains may be confidential, legally privileged and protected by law. Access by the intended recipient only is authorised. Any liability (in negligence or otherwise) arising from any third party acting, or refraining from acting, on any information contained in this e-mail is hereby excluded. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Copyright in this e-mail and attachments created by us belongs to The Digital Word Company Limited: the author also asserts the right to be identified as such and object to any misuse. The Digital Word Company Limited. Registered in the United Kingdom, number: 3416629. Registered Office: Batley Business & Technology Centre, Technology Drive, Batley, WF17 6ER, England. Internet: http://v3.digital-word.com/
RE: Connection to MySQL DB fails when mod_perl enabled...
Rodney, :: I propose that you reduce it to: :: :: # BEGIN MOD_PERL CONFIG :: LoadModule perl_module modules/ApacheModulePerl :: :: :: SetHandler perl-script :: PerlHandler Apache::Registry :: :: :: # END MOD_PERL CONFIG :: :: You'll see that I'm using *.mpl. This will insure that you don't :: have some :: other assosiation interfering. I had already tried ".plx" to no avail. I have made the change as you suggest and I still have the same error. I'm probably going to have to forfeit mod_perl after all. :-( Kindest regards, Jonathan M. Hollin Digital-Word.com
Re: Connection to MySQL DB fails when mod_perl enabled...
OK, here's the relevant part of your conf: # BEGIN MOD_PERL CONFIG LoadModule perl_module modules/ApacheModulePerl ScriptAlias /perl-bin/ "perl-bin/" PerlSendHeader On SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI # END MOD_PERL CONFIG I propose that you reduce it to: # BEGIN MOD_PERL CONFIG LoadModule perl_module modules/ApacheModulePerl SetHandler perl-script PerlHandler Apache::Registry # END MOD_PERL CONFIG You'll see that I'm using *.mpl. This will insure that you don't have some other assosiation interfering. --- Rodney Broom
RE: Connection to MySQL DB fails when mod_perl enabled...
:: Okay, then that's the problem. It's not running the script you think :: it's running. If you don't see 'Error:' in the error log, then you :: could change that script all day and your changes will never have any :: effect. But it is running the script I am requesting - I know this because when I comment out the DBI->connect it works perfectly. :: So either you're just running the wrong script, or the script has gotten :: cached under Apache::Registry and it's not noticing the latest version :: on disk. "cached under Apache::Registry" - well that's outside of my [limited] knowledge of Apache. Kindest regards, Jonathan M. Hollin Digital-Word.com
RE: Connection to MySQL DB fails when mod_perl enabled...
[EMAIL PROTECTED] (Jonathan M. Hollin) wrote: >:: Tom is saying that your error message should actually include the string: >:: 'Error: '. I'm wondering the same thing, what did ~that ~ error >:: message say? > >That's my point. I DO have the "or die" code in my script - it hasn't >changed the message reported in error.log. Believe me guys, I'm as confused >as you are. Okay, then that's the problem. It's not running the script you think it's running. If you don't see 'Error:' in the error log, then you could change that script all day and your changes will never have any effect. So either you're just running the wrong script, or the script has gotten cached under Apache::Registry and it's not noticing the latest version on disk. ------ Ken Williams Last Bastion of Euclidity [EMAIL PROTECTED]The Math Forum
RE: Connection to MySQL DB fails when mod_perl enabled...
:: I see what Tom is saying. You said that you found this in your error log: :: :: > [Tue May 22 01:39:47 2001] [error] DBI->connect failed: Can't :: connect to :: > MySQL server on 'localhost' (10061) at :: > e:/pad/htdocs/internet/system/frontpage.cgi line 33 :: :: But a previous message suggested trying to propogate your own :: error in the :: Perl code like this: :: :: $dbh = DBI->connect($dsn, dbusrname, dbpassword) :: or die "Error: $DBI::errstr"; :: :: If you use this method, then you should get a record in your error log :: simular to: :: "Error: some error message" :: :: Tom is saying that your error message should actually include the string: :: 'Error: '. I'm wondering the same thing, what did ~that ~ error :: message say? That's my point. I DO have the "or die" code in my script - it hasn't changed the message reported in error.log. Believe me guys, I'm as confused as you are. Kindest regards, Jonathan M. Hollin Digital-Word.com
Re: Connection to MySQL DB fails when mod_perl enabled...
I see what Tom is saying. You said that you found this in your error log: > [Tue May 22 01:39:47 2001] [error] DBI->connect failed: Can't connect to > MySQL server on 'localhost' (10061) at > e:/pad/htdocs/internet/system/frontpage.cgi line 33 But a previous message suggested trying to propogate your own error in the Perl code like this: $dbh = DBI->connect($dsn, dbusrname, dbpassword) or die "Error: $DBI::errstr"; If you use this method, then you should get a record in your error log simular to: "Error: some error message" Tom is saying that your error message should actually include the string: 'Error: '. I'm wondering the same thing, what did ~that ~ error message say? --- Rodney Broom
RE: Connection to MySQL DB fails when mod_perl enabled...
:: Sorry if I'm pointing out the obvious, but that's what you usually see in :: the browser. The real error message will be in your apache logs, :: quite often in /var/log/httpd/error_log, but defined in your apache :: configuration. I know Tom. I already posted the error log entry, but here goes anyway: [Tue May 22 01:39:47 2001] [error] DBI->connect failed: Can't connect to MySQL server on 'localhost' (10061) at e:/pad/htdocs/internet/system/frontpage.cgi line 33 Kindest regards, Jonathan M. Hollin Digital-Word.com
Re: Connection to MySQL DB fails when mod_perl enabled...
> I appreciate what you were looking for Ken. But that's the point - I don't > get an error string. All I get is an "Internal Server Error". > Sorry if I'm pointing out the obvious, but that's what you usually see in the browser. The real error message will be in your apache logs, quite often in /var/log/httpd/error_log, but defined in your apache configuration. -- Tom Lancaster Red Hat, Inc. [EMAIL PROTECTED] (510)-986-8770 x 354
RE: Connection to MySQL DB fails when mod_perl enabled...
:: What does 'failed' mean? What was the error? That's the point, you :: have to see the particular error string, starting with "Error:", to find :: out what's happening. I appreciate what you were looking for Ken. But that's the point - I don't get an error string. All I get is an "Internal Server Error". Kindest regards, Jonathan M. Hollin Digital-Word.com
RE: Connection to MySQL DB fails when mod_perl enabled...
:: JH> Yes I also have PHP4 installed and running properly (and am able :: JH> to connect to the MySQL server fine with PHP). :: :: Good, that establishes that your DB is working. Yes the database is working fine. Let me reiterate: DB is accessible via mysqladmin; DB is accessible via PHP; DB is accessible via CGI; DB is NOT accessible via mod_perl. :: JH> Removed PHP from Apache, that didn't help. :: JH> Nothing else is connecting to the MySQL server. :: :: I've never used a non-*NIX Apache. Do you need to restart you :: machine to get :: something(s) out of memory? Compile a new binary (I doubt it)? I don't think I have to restart the machine. I thought I only had to kill the Apache process, then restart it. However, I'll try a reboot... :: JH> Interestingly, the MySQL server error log contains nothing. :: No failed :: JH> access attempts, no other error codes. I presume this is :: significant? :: :: My thought would be that this indicates a driver problem. I would suggest :: creating a terribly minimized configuration that only includes :: the requisits :: and mod_perl stuff. Then see if that works. Yes, I think I should try this. I'll reboot now, then test. Then I'll build minimal script and test that. Will advise list of results. I would just like to say thank you to everyone for their help thus far. I am completely new to mod_perl, but an old hand with Perl and CGI. I appreciate your efforts. Kindest regards, Jonathan M. Hollin Digital-Word.com
RE: Connection to MySQL DB fails when mod_perl enabled...
[EMAIL PROTECTED] (Jonathan M. Hollin) wrote: >:: This is suspicious. The connect() is definitely where the error is >:: happening given what you wrote earlier. Try making sure, change it to: >:: >:: use DBI(); >:: $driver = "mysql"; >:: $dsn = "DBI:$driver:database=shapeshifter;host=localhost"; >:: $dbh = DBI->connect($dsn, dbusrname, dbpassword) >:: or die "Error: $DBI::errstr"; > >Done this - failed! What does 'failed' mean? What was the error? That's the point, you have to see the particular error string, starting with "Error:", to find out what's happening. ------ Ken Williams Last Bastion of Euclidity [EMAIL PROTECTED]The Math Forum
Re: Connection to MySQL DB fails when mod_perl enabled...
JH> Yes I also have PHP4 installed and running properly (and am able JH> to connect to the MySQL server fine with PHP). Good, that establishes that your DB is working. JH> Removed PHP from Apache, that didn't help. JH> Nothing else is connecting to the MySQL server. I've never used a non-*NIX Apache. Do you need to restart you machine to get something(s) out of memory? Compile a new binary (I doubt it)? JH> Interestingly, the MySQL server error log contains nothing. No failed JH> access attempts, no other error codes. I presume this is significant? My thought would be that this indicates a driver problem. I would suggest creating a terribly minimized configuration that only includes the requisits and mod_perl stuff. Then see if that works. --- Rodney Broom
RE: Connection to MySQL DB fails when mod_perl enabled...
:: JH> Yes I also have PHP4 installed and running properly (and am able to :: connect :: JH> to the MySQL server fine with PHP). I'll comment out the :: PHP code from :: JH> httpd.config and see if that helps... :: :: Cool, that could be it. If not, I'd get suspicious of anything :: else that can :: access Mysql. Removed PHP from Apache, that didn't help. Nothing else is connecting to the MySQL server. Interestingly, the MySQL server error log contains nothing. No failed access attempts, no other error codes. I presume this is significant? Kindest regards, Jonathan M. Hollin Digital-Word.com
RE: Connection to MySQL DB fails when mod_perl enabled...
:: This is suspicious. The connect() is definitely where the error is :: happening given what you wrote earlier. Try making sure, change it to: :: :: use DBI(); :: $driver = "mysql"; :: $dsn = "DBI:$driver:database=shapeshifter;host=localhost"; :: $dbh = DBI->connect($dsn, dbusrname, dbpassword) :: or die "Error: $DBI::errstr"; Done this - failed! Kindest regards, Jonathan M. Hollin Digital-Word.com
RE: Connection to MySQL DB fails when mod_perl enabled...
Oh the connect is definitely where it's failing. If I comment that out then everything works fine... I'll try your code though - watch this space. Kindest regards, Jonathan M. Hollin Digital-Word.com :: >:: how bout adding a 'or die DBI->errstr' to the above line to find :: >:: out whats :: >:: happening. :: > :: >Hmm... Tried that, it returns nothing!!! :-( :: :: This is suspicious. The connect() is definitely where the error is :: happening given what you wrote earlier. Try making sure, change it to: :: :: use DBI(); :: $driver = "mysql"; :: $dsn = "DBI:$driver:database=shapeshifter;host=localhost"; :: $dbh = DBI->connect($dsn, dbusrname, dbpassword) :: or die "Error: $DBI::errstr"; :: :: (include the whole string there)
RE: Connection to MySQL DB fails when mod_perl enabled...
[EMAIL PROTECTED] (Jonathan M. Hollin) wrote: >[EMAIL PROTECTED] (Mike Cameron) wrote: >:: how bout adding a 'or die DBI->errstr' to the above line to find >:: out whats >:: happening. > >Hmm... Tried that, it returns nothing!!! :-( This is suspicious. The connect() is definitely where the error is happening given what you wrote earlier. Try making sure, change it to: use DBI(); $driver = "mysql"; $dsn = "DBI:$driver:database=shapeshifter;host=localhost"; $dbh = DBI->connect($dsn, dbusrname, dbpassword) or die "Error: $DBI::errstr"; (include the whole string there) ------ Ken Williams Last Bastion of Euclidity [EMAIL PROTECTED]The Math Forum
RE: Connection to MySQL DB fails when mod_perl enabled...
:: You have several pieces of mod_perl configuration. If you leave it all in :: place, and try some mod_perl CGI without a DB connection, what happens? Everything works fine (tested several scripts yet and had no other problems - none of the others use DBI though). I am also using CGI.pm in the script that's failing. Kindest regards, Jonathan M. Hollin Digital-Word.com
Re: Connection to MySQL DB fails when mod_perl enabled...
JH> If I comment out the DBI code the rest of the script works fine. I have JH> test the MOD_PERL environment string and mod_perl is definitely running JH> okay. You have several pieces of mod_perl configuration. If you leave it all in place, and try some mod_perl CGI without a DB connection, what happens? --- Rodney Broom
RE: Connection to MySQL DB fails when mod_perl enabled...
:: This indicates that ~something~ should have gone to the error :: log. Can you tell us what else is there? Nothing, except: [Tue May 22 00:44:37 2001] nul: DBI->connect failed: Can't connect to MySQL server on 'localhost' (10061) at e:/pad/htdocs/internet/system/frontpage.cgi line 29 [Tue May 22 00:44:37 2001] [error] Can't connect to MySQL server on 'localhost' (10061) at e:/pad/htdocs/internet/system/frontpage.cgi line 29. :: Can you get a DB connection with regular CGI? Yes, no problem at all with regular CGI. But I already like the massive speed increase I've seen under mod_perl and don't want to lose it. If I comment out the DBI code the rest of the script works fine. I have test the MOD_PERL environment string and mod_perl is definitely running okay. Kindest regards, Jonathan M. Hollin Digital-Word.com
Re: Connection to MySQL DB fails when mod_perl enabled...
> A script that works just fine sans > mod_perl dies with error 500 (Internal Server Error) when mod_perl is > enabled for that file type: This indicates that ~something~ should have gone to the error log. Can you tell us what else is there? Can you get a DB connection with regular CGI? --- Rodney Broom
RE: Connection to MySQL DB fails when mod_perl enabled...
Hmm... Tried that, it returns nothing!!! :-( Kindest regards, Jonathan M. Hollin Digital-Word.com :: "Jonathan M. Hollin" wrote: :: :: > This is driving me crazy... is there anything special I need :: to do when :: > using DBI (DBD::MySQL) with mod_perl. A script that works :: just fine sans :: > mod_perl dies with error 500 (Internal Server Error) when mod_perl is :: > enabled for that file type: :: > :: > Web Server: Apache/1.3.19(Win32) mod_perl/1.24_01 on a Windows 2000 :: > server -- connecting to a MySQL 3.23.38-nt DB-server. :: > :: > Sample of httpd.conf: :: > :: > # BEGIN MOD_PERL CONFIG :: > LoadModule perl_module modules/ApacheModulePerl :: > ScriptAlias /perl-bin/ "perl-bin/" :: > PerlSendHeader On :: > :: > SetHandler perl-script :: > PerlHandler Apache::Registry :: > Options ExecCGI :: > :: > :: > :: > SetHandler perl-script :: > PerlHandler Apache::Registry :: > Options ExecCGI :: > :: > :: > :: > SetHandler perl-script :: > PerlHandler Apache::Registry :: > Options ExecCGI :: > :: > :: > # END MOD_PERL CONFIG :: > :: > Error Log entry: :: > :: > [Tue May 22 00:13:09 2001] nul: DBI->connect failed: Can't :: connect to MySQL :: > server on 'localhost' (10061) at :: e:/pad/htdocs/internet/system/frontpage.cgi :: > line 29 :: > [Tue May 22 00:13:09 2001] [error] Can't call method "prepare" on an :: > undefined value at e:/pad/htdocs/internet/system/frontpage.cgi line 30. :: > :: > Perl Code: :: > :: > use DBI(); :: > $driver = "mysql"; :: > $dsn = "DBI:$driver:database=shapeshifter;host=localhost"; :: > $dbh = DBI->connect($dsn, dbusrname, dbpassword); :: :: how bout adding a 'or die DBI->errstr' to the above line to find :: out whats :: happening. :: :: > :: > my $sth = $dbh->prepare("SELECT * FROM frontpage"); :: > $sth->execute(); :: > while (my $ref = $sth->fetchrow_hashref()) { :: > $body .= qq~Found a row: id = :: $ref->{'serial_number'}, name = :: > $ref->{'position'}~; :: > } :: > $sth->finish(); :: > $dbh->disconnect(); :: > :: > Any help appreciated. I have RTFMs but I can't reach any :: conclusions about :: > contention between mod_perl and MySQL... :: > :: > Kindest regards, :: > Jonathan M. Hollin :: > Digital-Word.com ::
Re: Connection to MySQL DB fails when mod_perl enabled...
"Jonathan M. Hollin" wrote: > This is driving me crazy... is there anything special I need to do when > using DBI (DBD::MySQL) with mod_perl. A script that works just fine sans > mod_perl dies with error 500 (Internal Server Error) when mod_perl is > enabled for that file type: > > Web Server: Apache/1.3.19(Win32) mod_perl/1.24_01 on a Windows 2000 > server -- connecting to a MySQL 3.23.38-nt DB-server. > > Sample of httpd.conf: > > # BEGIN MOD_PERL CONFIG > LoadModule perl_module modules/ApacheModulePerl > ScriptAlias /perl-bin/ "perl-bin/" > PerlSendHeader On > > SetHandler perl-script > PerlHandler Apache::Registry > Options ExecCGI > > > > SetHandler perl-script > PerlHandler Apache::Registry > Options ExecCGI > > > > SetHandler perl-script > PerlHandler Apache::Registry > Options ExecCGI > > > # END MOD_PERL CONFIG > > Error Log entry: > > [Tue May 22 00:13:09 2001] nul: DBI->connect failed: Can't connect to MySQL > server on 'localhost' (10061) at e:/pad/htdocs/internet/system/frontpage.cgi > line 29 > [Tue May 22 00:13:09 2001] [error] Can't call method "prepare" on an > undefined value at e:/pad/htdocs/internet/system/frontpage.cgi line 30. > > Perl Code: > > use DBI(); > $driver = "mysql"; > $dsn = "DBI:$driver:database=shapeshifter;host=localhost"; > $dbh = DBI->connect($dsn, dbusrname, dbpassword); how bout adding a 'or die DBI->errstr' to the above line to find out whats happening. > > my $sth = $dbh->prepare("SELECT * FROM frontpage"); > $sth->execute(); > while (my $ref = $sth->fetchrow_hashref()) { > $body .= qq~Found a row: id = $ref->{'serial_number'}, name = > $ref->{'position'}~; > } > $sth->finish(); > $dbh->disconnect(); > > Any help appreciated. I have RTFMs but I can't reach any conclusions about > contention between mod_perl and MySQL... > > Kindest regards, > Jonathan M. Hollin > Digital-Word.com