hi i am using the following code to connect to MySQL database but i am getting this error
Software error:
Global symbol "$db" requires explicit package name at C:/Program Files/Apache Group/Apache2/cgi-bin/data.cgi line 16.
Global symbol "$host" requires explicit package name at C:/Program Files/Apache Group/Apache2/cgi-bin/data.cgi line 17.
Global symbol "$user" requires explicit package name at C:/Program Files/Apache Group/Apache2/cgi-bin/data.cgi line 18.
Global symbol "$password" requires explicit package name at C:/Program Files/Apache Group/Apache2/cgi-bin/data.cgi line 19.
Global symbol "$db" requires explicit package name at C:/Program Files/Apache Group/Apache2/cgi-bin/data.cgi line 21.
Global symbol "$host" requires explicit package name at C:/Program Files/Apache Group/Apache2/cgi-bin/data.cgi line 21.
Global symbol "$user" requires explicit package name at C:/Program Files/Apache Group/Apache2/cgi-bin/data.cgi line 22.
Global symbol "$password" requires explicit package name at C:/Program Files/Apache Group/Apache2/cgi-bin/data.cgi line 23.
Execution of C:/Program Files/Apache Group/Apache2/cgi-bin/data.cgi aborted due to compilation errors.
code that is been used
Code:
#!C:\perl\bin\perl.exe
use DBI;
use CGI qw(:standard);
use warnings;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
print header;
print start_html("Results Page");
$db="Disease";
$host="localhost";
$user="root";
$password="mysql1234";
#connect to MySQL database
my $dbh = DBI->connect ("DBI:mysql:database=$db:host=$host",
$user,
$password)
or die "Can't connect to database: $DBI::errstr\n";
my $query = new CGI;
my %formdata = $query->Vars;
my $searchkey = $formdata{'star'};
my $sth = $dbh->prepare("select * from target where Target_type == $searchkey ");
$sth ->execute();
print '<table border="1">';
print '<tr><th>Key 1</th><th>key2</th><th>Target Name</th><th>Target Type</th><th>PDB ID</th><th>Modeled Structure</th><th>Uniprot
link</th><th>Disease Name</th><th>KEGG link</th></th>';
while (my @row = $sth->fetchrow_array) {
print
"<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td><td>$row[5]</td><td>$row[6]</td><td>$row[7]</td><td>$ro
w[8]</td></tr>\n";
}
print'</table>';
print end_html;
and the HTML script
HTML Code:
<html>
<head><Title> Query form </title></head>
<body>
<p> Welcome to database search
<p>
<hr>
<a href ="http://localhost/cgi-bin/test2.pl ">click here </a> to view Target database .
<p>
<hr>
<p> Searching for a Disease in Target database
<form action="http://localhost/cgi-bin/data.cgi" method="post" >
<!-- <p>Enter search Key : <input type="text" name="skey" /></p> -->
<p>Enter Target type : <input type="text" name="star" /></p>
<p><input type="submit" name="Submit" value="Submit Form" /></p>
</form>
</body>
</html>
please help me out with this