Gossamer Forum
Quote Reply
Perl with Mysql
I cant give a string value in where clause..
But It works when I give numeric value in where clause




#!/usr/bin/perl -w
use DBI;
$DB_name ='test2';
print "Enter Domain\n";
chop ($domain = <>);


#chomp $domain;
#print $domain;


$Domain_name="www.google.com";
$dbh = DBI->connect("dbi:mysql:dbname=$DB_name",'root','') or die "Connection Error: $DBI::errstr\n";




$sql = "select install_id from install_sites where hostname = ".$domain;




$sth = $dbh->prepare($sql);
$sth->execute()
or die "SQL Error: $DBI::errstr\n";
($id) = $sth->fetchrow_array();
#print "Install_id = ".$id;
$sql = "select fs_username,handler_id,shared_code_group_id from installs where id = $id";


$sth = $dbh->prepare($sql);
$sth->execute()
or die "SQL Error: $DBI::errstr\n";
($username,$handlerId,$sharedGroupId,) = $sth->fetchrow_array();
print "Install_id = ".$id;
print "\nfs_username = ".$username;
print "\nhandler_id = ".$handlerId;
print "\nshared_code_group_id = ".$sharedGroupId;
print"\n";
$dbh->disconnect;



Output
----------
Enter Domain
www.google.com


DBD::mysql::st execute failed: Unknown column 'www.google.com' in 'where clause' at new.pl line 23, <> line 1.
SQL Error: Unknown column 'www.google.com' in 'where clause'