Thanks for the idea. Thanks to it I found another solution that works well: Instead of creating special table you can also just use SHOW COLUMNS, feed it into an array and then use it as you mentioned. Hopefully you'll find it useful... Thanks again Mariusz
----- Original Message ----- From: "Tanton Gibbs" <[EMAIL PROTECTED]> To: "Mariusz" <[EMAIL PROTECTED]>; "perl" <[EMAIL PROTECTED]> Sent: Sunday, September 22, 2002 1:07 PM Subject: Re: MySql - Perl question > Often times, a separate table of valid choices exists in the database which > you can quickly search first. Usually, you would select everthing from the > table at startup time and put it in a hash, then when you need to process > the query, first lookup the users entry in the hash of choices. If it is > not found, then issue an error. > > HTH, > Tanton > ----- Original Message ----- > From: "Mariusz" <[EMAIL PROTECTED]> > To: "perl" <[EMAIL PROTECTED]> > Sent: Sunday, September 22, 2002 1:06 PM > Subject: MySql - Perl question > > > Hi, > > I have a "discount" table that carries percentage discounts that should be > looked up when the customer submits a discount code and taken into > calculation of the total price. My table looks something like this: > > field names: |senior|student|... > values: |0.20|0.50|... > > Now, when the senior writes in the textfield "senior"(as a discount code), > everything is fine since my SELECT query looks up $discount field (which in > this case is "senior") and returns 0.20. However, if by mistake he misspells > "senor" instead of "senior" (or tries to make up a discount code) he will > get an error, because there is no such field in my MySQL table. How can I > catch that error (such discount doesn't exist) and have perl do something? > > thanks, > Mariusz > > ps. My Select query looks up bunch of other stuff at the same time, but I > guess I could separate them into two and maybe react to the error caused > during discount lookup and have perl continue... but how can I do that? How > can I separate the error "such field doesn't exist" from any other error in > MySQL? Would "prepare" stop the script the same way "selectrow_array" does? > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]