Hi,
I am trying to use this code to test the mysql on my computer. Prior to running the code I've created a database - webdb, host = localhost, user name - webdv,
pass word - webdvpass; The code looks great - however, I got this error
DBI connect("host=localhost;database=webdv','webdv' ) failed Access denied for user: 'webdv@localhost' (Using password: YES) at firstdb.cgi line 15
#----------------------------------------------------------------------------
#!/usr/bin/perl
use warnings;
use CGI qw(:standard);
use DBI;
my( $dbc,$dbs );
my $count;
$dbc = DBI->connect("DBI:mysql:host=localhost;database=webdb","webdv","webdvpass",
{PrintError => 0,RaiseError => 1}
);
$dbs = $dbc->prepare( "SELECT salary, age, address FROM mine WHERE NAME LIKE 'dave%'" );
$dbs->execute();
print header(), start_html(-title=>'My Web' -bgcolor => 'green' );
$count = 0;
while( $dvals = $dbs->fetchrow_array() )
{
print p( sprintf("Salary : %s\n Age : %d\n, Address : %s\n",$dvals[0],$dvals[1],$dvals[2] ));
$count ++;
}
if( $count == 0 )
{
print p('No information found');
}
$dbs->finish();
$dbc->disconnect();
print end_html();
#----------------------------------------------------------------------------
I am trying to use this code to test the mysql on my computer. Prior to running the code I've created a database - webdb, host = localhost, user name - webdv,
pass word - webdvpass; The code looks great - however, I got this error
DBI connect("host=localhost;database=webdv','webdv' ) failed Access denied for user: 'webdv@localhost' (Using password: YES) at firstdb.cgi line 15
#----------------------------------------------------------------------------
#!/usr/bin/perl
use warnings;
use CGI qw(:standard);
use DBI;
my( $dbc,$dbs );
my $count;
$dbc = DBI->connect("DBI:mysql:host=localhost;database=webdb","webdv","webdvpass",
{PrintError => 0,RaiseError => 1}
);
$dbs = $dbc->prepare( "SELECT salary, age, address FROM mine WHERE NAME LIKE 'dave%'" );
$dbs->execute();
print header(), start_html(-title=>'My Web' -bgcolor => 'green' );
$count = 0;
while( $dvals = $dbs->fetchrow_array() )
{
print p( sprintf("Salary : %s\n Age : %d\n, Address : %s\n",$dvals[0],$dvals[1],$dvals[2] ));
$count ++;
}
if( $count == 0 )
{
print p('No information found');
}
$dbs->finish();
$dbc->disconnect();
print end_html();
#----------------------------------------------------------------------------