Hello I have redhat 7.1 and mysql  , I am trying to query DB of People
if there is no record for this person , I want to add them . My problem
seams to be what is in query results with it comes back blank
 
here is the code 
 
 

$dbh1 =DBI ->connect($data_source, $username, $password) or die "cant
connect to
 $data_source : my $dbh-> errstr\n";
my $sth1 = $dbh1 -> prepare("select owner from users where owner =
'$user_n'");
$sth1 -> execute or die " unable to execute query ";
 
# $sth1 -> finish;
# $dbh1->disconnect;
 
my $array_ref = $sth1 -> fetchall_arrayref();
 
  foreach $row(@$array_ref){
 

my($owner) = @$row;
 
  if($owner eq NULL){ 

 
$dbh4 =DBI ->connect($data_source, $username, $password) or die "cant
connect to
 $data_source : my $dbh-> errstr\n";
 
my $sth2 = $dbh4 -> prepare("insert into users(owner)values('$user_n')");
$sth2 -> execute or die " unable to execute query ";
 
    }
 

}
 

$sth -> finish;
 
#  look up results ??
 
 
 
 
 
thanks in advance
Jim
 
 
 
 
 

 
 
 
 
 

Reply via email to