List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:August 23 1999 9:52pm
Subject:Re: Error creation --
View as plain text  
At 4:42 PM -0500 8/23/99, Robert Pruitt wrote:
>I have a small table --
>CREATE TABLE diecast (
>     stock_number varchar(20) binary NOT NULL,
>     item_description tinyblob NOT NULL,
>     sales_price decimal(7,2) DEFAULT '0.00' NOT NULL,
>     class char(1) DEFAULT 'n' NOT NULL,
>     PRIMARY KEY (stock_number));
>And a small PHP script --
>$query = "INSERT INTO diecast VALUES ('$stock_number',
>'$item_description', '$sales_price', '$class')";
>My problem is the user sometimes enters sales price as $1.00 instead
>of 1.00 into the form text box. <input type=text name='sales_price'>
>No errors are forthcoming. He might sit there doing this for an hour,
>before realizing that now all his work shows price as $0.00 as the
>final result.
>Can I force an error if the user enters a $ into this field? What's
>the best way to handle this?

You have to validate the form input yourself before you enter it
into the database, perhaps by verifying it against some sort of
regular expression.

Paul DuBois, paul@stripped
Error creation --Robert Pruitt23 Aug
  • Re: Error creation --Paul DuBois23 Aug
  • Re: Error creation --ed24 Aug
    • Re: Error creation --Thimble Smith24 Aug