Hello, I am trying to convert a simple php
script to perl script but failed.

I tried to find a way to access the row by
name(something like $row[foobar] but all the examples
on the web says like $row[1] or so...

Here are the original php script and the perl
script I wrote so far (of course it has problems.)

The original php script is...

----
<?
$db = array('server' => 'localhost',
                                'user'   => 'bar',
                                'pass'   => '',
                                'name'   => 'foo' );

mysql_connect($db[server], $db[user], $db[pass]);
mysql_select_db($db[name]);

$result = mysql_query("SELECT * FROM T_Comments");

while ($A = mysql_fetch_array($result)) {
        if ($A[Author] && $A[AuthorEmail])
                mysql_query("UPDATE T_Comments SET
score = 1 WHERE Rid = '$A[Rid
]'");
}

echo "done!!!!";
?>
----

And the perl script is

----
#!/usr/bin/perl -w

use DBI;
use strict;

my $dbh = DBI->connect('DBI:mysql:foo', 'bar', '') or
die "Cannot connect to server\n";

my $sth = $dbh->prepare("SELECT * FROM T_Comments");

$sth->execute;

my @A;

while (@A = $sth->fetchrow_array) {
        if ($A->Author && $A->AuthorEmail)
                $dbh->do("UPDATE T_Comments SET score
= 1 WHERE Rid = '$A[Rid]'"
);
}

$sth->finish;
$dbh->disconnect;

exit(0);
----
Could anyone please let me know where to modify?

Thanks very much.

_____________________________________________________________________
�� �ٸ� ��! ������ �ƹ�Ÿ ����� - ����! �ƹ�Ÿ
http://avatar.yahoo.co.kr/
�Ϸ����� �̾߱��ص� �ð����� �� �𸣴� - ����! ä��
http://chat.yahoo.co.kr/

Reply via email to