Like others said, the problem could be in the printing phase itself, I'm not going to repeat here.

Since you're a beginner, I would like to comment your code and give you some hopefully useful hints.

You'll find much more information checking out Learning CGI & DBI well and with a Super Search.

First of all, your use of quotes inside a SQL string can be dangerous and unportable. For example, if $model contains a single quote, your query is doomed to fail miserably...

There are at least two easy solutions, both discussed elsewhere like I said. You can use the quote method, or placeholders. The former is a DBI method that you call passing a string, obtaining its quoted (thus safe to use in SQL) version in return. It's brilliant because it takes care of all the specific quoting methods of different databases, that's what DBI is about after all. The latter allows yuo to put ? in a SQL string where a needed value is unknown, and you can specify it later, for example at execute time. Quoting is added automagically when needed.

Then I see you're using global variables for returning your values. That's really bad practice, it doesn't matter if it's just an example. It's dangerous, wrong and can be avoided very easily.

For example, the last statement of your function could be

return $hash{key1}, $hash{key2}, $hash{key3};

and the calling code could simply use the needed local variables to store the returned values:

($field1, $field2, $field3) = function(arguments);

or, equally:

@array_of_fields = function(arguments);

Finally, never forget to use strict; and the -w switch of the Perl interpreter. Not only it helps you designing your code more clearly, it also helps you avoiding common stupid mistakes like spelling errors or using undefined variables. Simply acquire the habit. Many people (me included) do it even for one-liners, throw away scripts.

I hope this helps, even though it does not answer directly to yuor question.

-- TMTOWTDI


In reply to (OT) Re: mysql no records after space by trantor
in thread mysql no records after space by drivle

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.