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;

$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);
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);
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;

Enter Domain

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'
Subject Author Views Date
Post Perl with Mysql harikrishnan 5433 Jun 2, 2011, 11:58 PM