Hi, I have a database query that works fine in the mysql console:

mysql> select Preferences.i_preference_desc, Preference_Desc.name, Pre +ference_Desc.value as range_value, Preferences.value as value, Prefer +ence_Desc.def_value from Preferences, Preference_Desc WHERE Preferenc +es.i_preference_desc=Preference_Desc.i_preference_desc and i_account= +894; +-------------------+------------------+------------------------------ +------+-----------------------+-----------+ | i_preference_desc | name | range_value + | value | def_value | +-------------------+------------------+------------------------------ +------+-----------------------+-----------+ | 0 | mode | voicemail, auto_attendant + | voicemail | voicemail | | 1 | password | + | 777 | | | 2 | password_ask | yes, no + | no | no | | 3 | prompt_levels | standard, extended, rapid + | standard | standard | | 4 | announce_dt | yes, no + | no | no | | 5 | auto_play | yes, no + | no | no | | 6 | greetings | standard, extended, personal, + name | personal | standard | | 7 | fax_file | multi_png, multi_tiff, pdf, t +iff | pdf | pdf | | 8 | iso_639_1 | RefB=Languages + | en | en | | 9 | ext_email | + | robscovell@notonyournelly.com | | | 10 | ext_email_action | none, forward, notify, copy + | forward | none | +-------------------+------------------+------------------------------ +------+-----------------------+-----------+ 11 rows in set (0.00 sec)

However, when I use code to do the same thing, I simply get a column of 'no' for 'value'. Here is my code:

$sql="select Preferences.i_preference_desc, Preference_Desc.name, Pref +erence_Desc.value as range_value, Preferences.value as value, Prefere +nce_Desc.def_value from Preferences, Preference_Desc WHERE Preference +s.i_preference_desc=Preference_Desc.i_preference_desc and i_account=? +"; my $sth2 = $dbh2->prepare($sql); $sth2->execute($account); my $preferences = {}; while (my $row = $sth2->fetchrow_hashref) { $preferences->{$row->{name}} = { value => $row->{value}, range_val +ue => $row->{range_value}, def_value => $row->{def_value} }; warn $row->{value}; } $sth2->finish();

This is the output from the warn line:

no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4. no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4. no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4. no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4. no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4. no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4. no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4. no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4. no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4. no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4. no at /home/beechams/new_gui/cu_accounts/voicemail_options.html line 9 +4.

Is there a bug in DBI or can't I see the obvious bug in my code ... ? def_value, name etc. all come out fine.

READMORE tags added by Arunbear


In reply to DBI gives out wrong data by robscov

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.