On Wed, 21 Jul 1999, Chris Lambrou wrote:
>Hello,
>
>I know I am doing something wrong here, just can't figure it
>out. I am using the following PERL code to connect to my local
>mysql server:
>
>-------------------------
>print "Content-Type: text/html\n\n";
>use Mysql;
>$dbh = Mysql->Connect('localhost', 'z100' ,'Z100' ,'z100club+');
>
>if (not $dbh) {
> print "Could Not connect to database.\n";
> print "Reason: $Mysql::db_errstr";
>} else {
> print "Connected";
>}
<SNIP>
Well, for starters, I would recommend using DBI.
If you haven't downloaded the latest, get it from CPAN.
It's Msql-Mysql-modules-1.2201.tar.gz
Try something like this.
#! /usr/bin/perl -wT
use CGI;
use DBI;
use strict;
my $dbname = 'somedb';
my $dbuser = 'someusr';
my $dbpass = 'somepwd';
#--- connect to database
my $dbh = DBI->connect("dbi:mysql:$dbname", $dbuser, $dbpass)
|| die "Couldn't connect to $dbname: $DBI::errstr\n";
my $form = new CGI;
print $form->header();
print $form->start_html;
print "Connected";
print $form->end_html();
<SNIP>
>( The $Mysql::db_errstr string is EMPTY!!! )
It sounds like your connect string failed to read in the variables.
Slan,
Micheal
---
Micheal Mc Evoy mjmc@stripped
http://www.whitepine.com
WhitePine Consulting supports the Free Software Foundation and it ideals
by promoting, using and supporting Open Source, GNU and GPL'd Software.