Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another perl mysql question with sth->fetch

Status
Not open for further replies.

iluvperl

Programmer
Jan 22, 2006
107
Code:
my $dbh = DBI->connect("DBI:mysql:$dbase", $mysql_user, $mysql_pass) or
print DBI->errstr;

my $data = qq(SELECT search, engine, time FROM searches WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= time);

my $sth = $dbh->prepare($data);
$sth->execute() or die $dbh->errstr;

my ($search, $engine, $date);
$sth->bind_columns(\$search, \$engine, \$date);

while($sth->fetch)
{
  print "$search $engine on $date<br>";
}

only prints out one record when there are 6 in total that should be printing and I can't for the life of me figure out WHY it's ignoring the other ones that match the time.<p>

This is a copy/paste from PHPMyAdmin in cpanel
Code:
        Edit	Delete	1  	this is fun  	Google  	2006-08-10 10:48:21
	Edit 	Delete 	2 	oh yeah	 	About 		2006-08-10 11:15:18
	Edit 	Delete 	3 	yet another	About 		2006-08-10 11:15:26
	Edit 	Delete 	4 	this is fun 	Excite 		2006-08-10 11:15:35
	Edit 	Delete 	5 	another on this	Excite 		2006-08-10 11:15:44
	Edit 	Delete 	6 	testing 	Dogpile 	2006-08-10 11:15:592006-08-10 11:15:59

Can anyone help me figure out why it's not drawing back all applicable records?
 
Try printing out $data, I've a feeling that it's not the actual query you think it is ...

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top