J
Joe Blower
When I execute the following SQL statement at the mysql> prompt, I get a
random result:
SELECT proxy FROM proxies WHERE active = 1 ORDER BY RAND() LIMIT 1;
When I wrap it in my perl code, I always get the first row in the database.
my $dbh = DBI->connect("dbi:mysql:$db:host=$db_host", $db_user, $db_pass);
my $sql = "SELECT proxy FROM proxies WHERE active = 1 ORDER BY RAND() LIMIT
1";
my $sth = $dbh->prepare($sql) or die $dbh->errstr;
$sth->execute() or die $dbh->errstr;
while (my $row = $sth->fetch())
{
$proxy = $row->[0];
}
Motiv8x
Top25Web.com: Ranking Report & Search Engine Forums
http://www.top25web.com
random result:
SELECT proxy FROM proxies WHERE active = 1 ORDER BY RAND() LIMIT 1;
When I wrap it in my perl code, I always get the first row in the database.
my $dbh = DBI->connect("dbi:mysql:$db:host=$db_host", $db_user, $db_pass);
my $sql = "SELECT proxy FROM proxies WHERE active = 1 ORDER BY RAND() LIMIT
1";
my $sth = $dbh->prepare($sql) or die $dbh->errstr;
$sth->execute() or die $dbh->errstr;
while (my $row = $sth->fetch())
{
$proxy = $row->[0];
}
Motiv8x
Top25Web.com: Ranking Report & Search Engine Forums
http://www.top25web.com