Database Query

Hello,
This may sound silly, but I can't seem to get my results out of a
database query. I can do this fine in Ruby on Rails, but from a Ruby
script, I can't seem to. I know my query works because I've already
tested it. My code is as follows:

require 'mysql'
create_log = File.new("comparison_imei.html", "w")
db = Mysql.connect("localhost", "root", "root", "compare_imei")

@num_perfect_matches = db.query("
      SELECT COUNT(*) AS n
      FROM att
      JOIN bes
        ON att.att_imei = bes.bes_imei
      ORDER BY
        att.att_name")

for num in @num_perfect_matches
@numberofrows = num['n']
create_log.puts @numberofrows
end

This gives me the following error:
compare_imei.rb:22: undefined method `each' for nil:NilClass
(NoMethodError)

Is there a proper way to get data out of my query?

Thanks,
- Jeff Miller

···

--
Posted via http://www.ruby-forum.com/.