Hi,
Here's your scipt
#!/usr/bin/perl
# This line above needs to point to your perl program, check with your
# ISP to make sure you have the right one. The #! is called She-Bang,
# just ask where the Perl She-Bang line needs to point to and they
# will probably know what you are talking about. Also make sure
# that this is the first line in the script, no space above it.
use DBI; #if you have Mysql it is likely that the DBI mod is installed.
# run the script from a command line first before setting it up
# as a cron to see that it works right.
$dbh= DBI->connect('DBI:mysql:MyDataBase_:localhost','iact','guestpast',undef)
|| die "Failed on DBI connect\n\n";
# Notice here that the qq` is not a single quote, it is the mark on the
# same key as the ~
my $q = qq` update gnews
set link = concat("http://www.myWeb.com/click/out.php?", link)
where link not like '%www.myWeb.com/click/out.php?%'
`;
my $sth = $dbh->prepare($q);
$sth->execute;
$q = qq` update ArticleTest
set link = concat("http://www.myWeb.com/click/out.php?", link)
where link not like '%www.myWeb.com/click/out.php?%'
`;
$sth = $dbh->prepare($q);
$sth->execute;
# make sure you do this especially with cronjobs #
$dbh->disconnect;
__END__
Thanks,
webadept-ga |
Clarification of Answer by
webadept-ga
on
30 Dec 2002 16:37 PST
By the way, just a personal note here. I would setup different update
scripts for each update you want to do, I put both in here to show how
that is done, but from a management stand point, I would take out the
second sql update, make a copy of this and put once in each script
file. This way, if something goes wrong with one of the scripts a) the
other might still work, and b) you can trouble shoot it much faster.
For instance, if both stop working for some reason it is probably the
server or the database, not the scripts, if only one stops, you can be
pretty sure something happened either with that table or the script
itself.
Thanks again,
webadept-ga
|