Hello , I have a user DB , My perl script on my redhat box scans a drive for
users files , and I want to email, the user to remind them they have a file
that they havent used in months

my problem  when the script comes accrosed a new user I want them to be
added to the DB and send me an email stating so , so I can look up their
email address and provide it. My script querys the DB to see if there is a
record , But I am not getting the right negitive response , to run my if
statement.


My DB :



+---------+----------------------------+------+
| owner   | email                      | comm |
+---------+----------------------------+------+
| t0642k8 | [EMAIL PROTECTED] |      |
+---------+----------------------------+------+
1 row in set (0.08 sec)

mysql>



my code    : please note I trimed it up



#####################################################
##                                                 ##
##   select distinct owner phase                   ##
##                                                 ##
#####################################################

my $database = "shared";
my $data_source = "DBI:mysql:$database";
my $username = "root";
my $password = "elaine";


$dbh = DBI ->connect($data_source, $username, $password) or die "cant
connect to

 $data_source : my $dbh-> errstr\n";

#################    Select Owner


my $sth= $dbh-> prepare("select distinct owner from files");

$sth-> execute or die " unable to execute query ";
my $array_ref = $sth->fetchall_arrayref();



open(LOG,"> /var/www/html/bad/users.txt");


   foreach $row(@$array_ref) {


#############################################################
##  dump total bad users to text file
#############################################################

 my ($user_n) = @$row;

     print LOG "$user_n\n";




#add to users DB





$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 ""){   ### try NULL next


print "Entered bracket \n";

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


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <mysql-unsubscribe-##L=##[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to