For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Freelance > March 2004 > perl & MySQL query









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author perl & MySQL query
DM

2004-03-19, 1:25 pm

Hi,

I am working on a Perl script which queries a MySQL table and displays the
results in a table in the web page. Everything works fine, but I would like
to get a message if the query does not return anything.

The MySQL table contains books in a library. For examply, if I do a search
by ISBN and choose 3333 as keyword (suppose there is no such ISBN number in
the ISBN field), the result of the query is null; however I would like to
display a message.

Thank you.





Vorxion

2004-03-19, 1:25 pm

In article <bX0ob.7046$Tf.878203@news20.bellglobal.com>, DM wrote:
>Hi,
>
>I am working on a Perl script which queries a MySQL table and displays the
>results in a table in the web page. Everything works fine, but I would like
>to get a message if the query does not return anything.
>
>The MySQL table contains books in a library. For examply, if I do a search
>by ISBN and choose 3333 as keyword (suppose there is no such ISBN number in
>the ISBN field), the result of the query is null; however I would like to
>display a message.


Thank you for telling us what you're doing and how you want it to work.

Of course, we're missing a few key pieces of information, like what you
actually want anyone to -do- about it, how much you're willing to pay to
have anything done (if you indeed do want someone to do anything), or if you
just want information how much you're willing to pay for that, etc.

But thanks for updating us on the status of your project. I know we're all
short enough on things to read that we didn't at all mind the gratuitous
explanation. :)

--
Vorxion - Member of The Vortexa Elite
Malcolm Dew-Jones

2004-03-19, 1:25 pm

DM (dm@nospam.com) wrote:
: Hi,

: I am working on a Perl script which queries a MySQL table and displays the
: results in a table in the web page. Everything works fine, but I would like
: to get a message if the query does not return anything.

: The MySQL table contains books in a library. For examply, if I do a search
: by ISBN and choose 3333 as keyword (suppose there is no such ISBN number in
: the ISBN field), the result of the query is null; however I would like to
: display a message.

I don't know your variables and etc, so I can only show pseudo code, but
what about something like



if no_results_found
then
print "<font color:red>Not found</font>";
end if;

Vorxion

2004-03-19, 1:25 pm

In article <3fa15be2@news.victoria.tc.ca>, Malcolm Dew-Jones wrote:
>DM (dm@nospam.com) wrote:
>: Hi,
>
>: I am working on a Perl script which queries a MySQL table and displays the
>: results in a table in the web page. Everything works fine, but I would like
>: to get a message if the query does not return anything.
>
>: The MySQL table contains books in a library. For examply, if I do a search
>: by ISBN and choose 3333 as keyword (suppose there is no such ISBN number in
>: the ISBN field), the result of the query is null; however I would like to
>: display a message.
>
>I don't know your variables and etc, so I can only show pseudo code, but
>what about something like
>
>
>
> if no_results_found
> then
> print "<font color:red>Not found</font>";
> end if;


Non-sarcastically (boy, he hit me wrong last night!), I don't think that's
his problem. I was betting that he doesn't know how to check for a failed
lookup from MySQL. That's how the post hit me.

This is a poster child for how -not- to ask for help.

Hell, send -him- to the Indian or Russian programmers! :)

--
Vorxion - Member of The Vortexa Elite
DM

2004-03-19, 1:25 pm

Well... that's what I was thinking of, but I was not sure how to implement
"no_results_found"...
Actually I just thought of something... I'll try it tomorrow, too late now,
time to go to bed :)



"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
news:3fa15be2@news.victoria.tc.ca...
> DM (dm@nospam.com) wrote:
> : Hi,
>
> : I am working on a Perl script which queries a MySQL table and displays

the
> : results in a table in the web page. Everything works fine, but I would

like
> : to get a message if the query does not return anything.
>
> : The MySQL table contains books in a library. For examply, if I do a

search
> : by ISBN and choose 3333 as keyword (suppose there is no such ISBN number

in
> : the ISBN field), the result of the query is null; however I would like

to
> : display a message.
>
> I don't know your variables and etc, so I can only show pseudo code, but
> what about something like
>
>
>
> if no_results_found
> then
> print "<font color:red>Not found</font>";
> end if;
>



Vorxion

2004-03-19, 1:25 pm

In article <jXkob.8840$Tf.1070415@news20.bellglobal.com>, DM wrote:
>Well... that's what I was thinking of, but I was not sure how to implement
>"no_results_found"...


Assuming you're being smart and using DBI and DBD::mysql, try:

if ($db_sth->rows == 0) {
# We had no matching rows, do whatever
}

perldoc DBI
perldoc DBD::mysql

It's all right there.

$75 - answer
$100 - not RTFM before asking

Total: $175

--
Vorxion - Member of The Vortexa Elite
DM

2004-03-19, 1:25 pm

Thank you.

"Vorxion" <vorxion@knockingshopofthemind.com> wrote in message
news:3fa29b52$1_1@news.iglou.com...
> In article <jXkob.8840$Tf.1070415@news20.bellglobal.com>, DM wrote:
implement[color=darkred]
>
> Assuming you're being smart and using DBI and DBD::mysql, try:
>
> if ($db_sth->rows == 0) {
> # We had no matching rows, do whatever
> }
>
> perldoc DBI
> perldoc DBD::mysql
>
> It's all right there.
>
> $75 - answer
> $100 - not RTFM before asking
>
> Total: $175
>
> --
> Vorxion - Member of The Vortexa Elite



Malcolm Dew-Jones

2004-03-19, 1:25 pm

Vorxion (vorxion@knockingshopofthemind.com) wrote:
: In article <jXkob.8840$Tf.1070415@news20.bellglobal.com>, DM wrote:
: >Well... that's what I was thinking of, but I was not sure how to implement
: >"no_results_found"...

Assuming you're being smart and using DBI and DBD::mysql, try:

perldoc DBI


: if ($db_sth->rows == 0) {
: # We had no matching rows, do whatever
: }

: perldoc DBI
: perldoc DBD::mysql

: It's all right there.

: $75 - answer
: $100 - not RTFM before asking

: Total: $175

: --
: Vorxion - Member of The Vortexa Elite

--
Vorxion

2004-03-19, 1:25 pm

In article <3fa42e9f@news.victoria.tc.ca>, Malcolm Dew-Jones wrote:
>Vorxion (vorxion@knockingshopofthemind.com) wrote:
>: In article <jXkob.8840$Tf.1070415@news20.bellglobal.com>, DM wrote:
>: >Well... that's what I was thinking of, but I was not sure how to implement
>: >"no_results_found"...
>
>Assuming you're being smart and using DBI and DBD::mysql, try:
>
>perldoc DBI


We're -such- bastards. We expect people to RTFM. :)

I think we should put a moratorium on helping anyone who isn't willing to
pay, period. It's not alt.comp.perlcgi.helpdesk, you know.

And then, they not only don't want to pay, they don't want to bother
reading the docs. Do the words, "Sod off!" mean anything to them, you
think?

--
Vorxion - Member of The Vortexa Elite
Art Sackett

2004-03-19, 1:25 pm

Vorxion <vorxion@knockingshopofthemind.com> wrote:

> We're -such- bastards. We expect people to RTFM. :)


That's what TFM is for, methinks.

> I think we should put a moratorium on helping anyone who isn't willing to
> pay, period. It's not alt.comp.perlcgi.helpdesk, you know.


The part that has always concerned me when "helping" someone who
obviously has no business writing apps that are exposed to the world is
that one day the inevitable crack will happen, and it will be one that
was preventable had the employer/school/dad's buddy from work/whatever
simply accepted that he could only expect professional results if he
were to hire a professional.

> And then, they not only don't want to pay, they don't want to bother
> reading the docs.


Which is why learning the hard way is in their best interest. If
falling didn't hurt, none of us would have bothered learning to walk.

> Do the words, "Sod off!" mean anything to them, you
> think?


Nope. They'll repost, and repost, then massively cross-post, until
finally someone gives an almost accurate answer, then cry about how
unfriendly we are.

--
Art Sackett,
Patron Saint of Drunken Fornication
David Gardner

2004-03-19, 1:26 pm

Surely if you wanted money you wouldn't have been so stupid as to offer good
advice in the first place ;)

And honeslty how many manuals have you truely read.


David

The early bird always catches the worm, but the late bird wakes up without a
hangover.


"Vorxion" <vorxion@knockingshopofthemind.com> wrote in message
news:3fa4330c$1_1@news.iglou.com...
> In article <3fa42e9f@news.victoria.tc.ca>, Malcolm Dew-Jones wrote:
implement[color=darkred]
>
> We're -such- bastards. We expect people to RTFM. :)
>
> I think we should put a moratorium on helping anyone who isn't willing to
> pay, period. It's not alt.comp.perlcgi.helpdesk, you know.
>
> And then, they not only don't want to pay, they don't want to bother
> reading the docs. Do the words, "Sod off!" mean anything to them, you
> think?
>
> --
> Vorxion - Member of The Vortexa Elite



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com