Re: mysql connection failing as CGI



ianatkinsonbsc@xxxxxxxxx writes:

I have a strange problem and I'm hoping someone can help. I've bought
some new hosting which comes with a MySQL database but I'm struggling
to get it working with any perl scripts; the hosting support are being
no help so I've had to come here, sorry guys!

The problem basically is that when the script is run as a CGI script it
won't connect to the database, however if I run the same script from
the command line (I have SSH access to the server) it runs fine.

The script is as follows (very simple):

--------------------------------------------------

#! /usr/bin/perl

use strict;
use warnings;

use DBI;

print "Content-type: text/html\n\n";
print "<html><head></head><body>\n\nres:\n\n";

$dbh = DBI->connect('DBI:mysql:dbname:213.171.218.249:3306', 'dbuser',
'dbpass') || die "Content-type:text/html\n\ncon err!";

Well, the first thing to do is ask Perl what went wrong:

my $dbh = DBI->connect('...');
if ( $dbh->err ) {
print 'DBI Error: ', $dbh->errstr, '<br>';
exit;
}

As you can see it connects to the database and retrieves the 3 ints sat
in there. If I run this from the CGI-bin however the only code output
is:

When a database connection succeeds for one user but fails for another, the
most common cause is that the server account has a different level of access
to the database. For instance, the web server process may be running inside
of a chroot "jail" in which /tmp/mysql.sock isn't visible.

There are any number of guesses I could give you though - Asking the database
handle for its error string will tell you for certain what went wrong.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
.



Relevant Pages

  • IBM Informix Web DataBlade: Local root by design
    ... IBM Informix Web DataBlade: Local root by design ... Impact: Any user who can: 1) Save a Perl script anywhere on the server's ... admin right on any database can do it by loading the WDB module into ...
    (Bugtraq)
  • Re: free unreferenced scalar error
    ... >> The test script is as trim as it gets. ... If the database is other than SQL Server the ... This is perl, v5.8.4 built for MSWin32-x86-multi-thread ... Step 2: Copy script file ...
    (perl.dbi.users)
  • Re: Server-side script executed on page load or event, but not SSI
    ... I'm sorry I used the term 'database'. ... I know I can do it simply by linking to the script, ... for running a perl script automagically when a page is loaded. ... Are there any other perl alternatives? ...
    (comp.lang.perl.misc)
  • Re: mysql connection failing as CGI
    ... some new hosting which comes with a MySQL database but I'm struggling ... to get it working with any perl scripts; the hosting support are being ... The problem basically is that when the script is run as a CGI script it ... the command line it runs fine. ...
    (comp.lang.perl.misc)
  • mysql connection failing as CGI
    ... some new hosting which comes with a MySQL database but I'm struggling ... to get it working with any perl scripts; the hosting support are being ... The problem basically is that when the script is run as a CGI script it ... the command line it runs fine. ...
    (comp.lang.perl.misc)