Okay, this is a strange one.

I have a perl script that generates a user report for our site by hitting the MySQL database. Normally, I would use straight SQL to generate the report, but that query takes FOREVER because you wind up joining a particular table to itself several times. (For the record, I didn't design this, we're using drupal.)

Now, the report runs fine on the test and staging servers. However, when I move to the production server, there is a problem. At one point, I build a query to his the user profile tables to grab a value for the user:

# Open cursor $imm_qy = "SELECT pv.value FROM profile_values pv, profile_fields pf + WHERE pv.uid = $uid and pv.fid = pf.fid and pf.name = 'profile_magaz +ine'"; print "\$imm_qy is $imm_qy .\n"; $immh = $dbh->prepare($imm_qy) or die "Cannot prepare magazine query +: " . $dbh->errstr . "\n"; # Execute query $immh->execute or die "Cannot execute magazine query: " . $dbh->errs +tr . "\n"; $imm = $immh->fetchrow_array; $immh->finish; print "For uid of $uid, \$imm is $imm .\n";

Note: the prints are in there to make sure that I'm acutally building these queries correctly, and apparently I am:

imm_qy is SELECT pv.value FROM profile_values pv, profile_fields pf WH +ERE pv.uid = 17 and pv.fid = pf.fid and pf.name = 'profile_magazine' + . For uid of 17, $imm is .

This is odd, because $imm should have a value at this point. In fact, if I go into a mysql session and copy-and-paste that command, I get the value of '1'. But for some users, it returns nothing. And here's the kicker: it's always the same users and it is 100% repeatable. So it must be an environment issue between the machines.

The test and staging server are identical, using Perl 5.8.6; MySQL Ver 14.7 Distrib 4.1.20, for redhat-linux-gnu (i386) using readline 4.3; and the same version of Red Hat Linux. Ditto for the production server. The only difference I can find is that the production server is using 1.50 of DBI, while the test and staging servers are using 1.48. Now, does ANYONE know of ANYTHING between 1.48 and 1.50 of DBI that *might* cause something like this? I am absolutely at a loss.

Thanks in advance.

--
tbone1, YAPS (Yet Another Perl Schlub)
And remember, if he succeeds, so what.
- Chick McGee


In reply to DBI and MySQL issue by tbone1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.