|
#!/usr/bin/perl
use DBI;
use CGI qw(param);
$name1 = param("name");
$lover_name1=param("lover_name");
$per=int(rand(101));
$db="db";
$host='192.168.10.3';
$userid="sanjay";
$passwd="sanjay";
$connectionInfo="dbi:mysql:$db;$host";
# make connection to database
$dbh =
DBI->connect($connectionInfo,$userid,$passwd)
;
# prepare and execute query
$query = "SELECT * FROM cal WHERE $name =
$name1 AND $lover_name = $lover_name1";
$sth = $dbh->prepare($query);
$sth->execute();
# assign fields to variables
$sth->bind_columns(\$name, \$lover_name,
\$per);
# output name list to the browser
while($sth->fetch()) {
print "present";
}
$sth->finish();
# disconnect from database
$dbh->disconnect;
print "Content-type:text/html\n\n";
print "<HTML><HEAD>";
print "<TITLE>CGI Test</TITLE>";
print "</HEAD>";
print "<BODY><H2>percentage is $per</H2>";
print "</BODY></HTML>";
i am getting error as
DBD::mysql::st execute failed: You have an error in your SQL syntax near '= AND = ' at line 1 at ./luv2.pl line 19.
Statement has no result columns to bind (perhaps you need to successfully call execute first) at ./luv2.pl line 22.
kindly reply..
|
|
|
|
|
|
|
// |