Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
JRSweets
Worker
Worker



Joined: Aug 06, 2004
Posts: 192

PostPosted: Sun Dec 12, 2004 8:38 pm Reply with quote

I am try to check something before its entered into the database to make sure it a percent between 1.0% - 100.0%. What would I need to use a regular expression?

Code:
if(!preg_match("", $new['qotm_table_width']))

         {
                 message_die(GENERAL_ERROR, "You must enter a percentage for the table width");
         }
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sun Dec 12, 2004 10:06 pm Reply with quote

Rather than do that, I would use this. This assumes that only integers will be entered.
Code:
$intQotm = (int) $qotm_table_width;

if (!($intQotm>=1 AND $intQotm<=100)) {


If fractions can get entered, then just use
Code:
$intQotm = (float) $qotm_table_width;

if (!($intQotm>=1 AND $intQotm<=100)) {
 
View user's profile Send private message
JRSweets







PostPosted: Mon Dec 13, 2004 8:04 am Reply with quote

Thank you! That worked great. RavensScripts
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©