You are here: Re: Check before insert in Database « PHP Programming Language « IT news, forums, messages
Re: Check before insert in Database

Posted by Gordon Burditt on 05/22/06 00:26

>I would to know how to check the value I am getting from an HTML form.
>
>Let's put it that way, I need to get a string and I would like to make sure
>this is a string and not a number for instance.

Everything you get from $_POST is a string. It might also be the
string representation of a number.

Make checks appropriate for the specific data involved. PHP has
all sorts of nice string functions to pick strings apart, to do
regular expression matching, etc. If a serial number is supposed
to be a letter followed by 5 digits, you might match it against
"[A-Za-z][0-9][0-9][0-9][0-9][0-9]".

is_numeric() checks for a string that could be interpreted as a number.
It allows signs, decimal points, and exponential notation.

>What kind of test could I use to check that?
>
>//here is the line where I get the value
>
>$variable = $_POST['value'];
>
>The point is I have to insert the data in an Oracle database. And I would
>like to test it before sending the data to the database.

That's a very good idea, but I don't see what kind of field has restrictions
like "any string that isn't a number".

Gordon L. Burditt

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация