Just some more information. It appears that the session variable
$formsave["dob"] is causing the problem. If I echo the input $_POST['dob']
it shows correctly, but when it's put into $formsave["dob"]  the leading and
ending 0's are being stripped.

B.

----- Original Message -----
From: "John W. Holmes" <[EMAIL PROTECTED]>
To: "'Beauford'" <[EMAIL PROTECTED]>; "'PHP General'"
<[EMAIL PROTECTED]>
Sent: Sunday, March 30, 2003 2:28 PM
Subject: RE: [PHP] Ereg question


> > I am using ereg to validate the format of a date entry (mm/dd/yy), but
> if
> > the year ends in a 0, it is being stripped and as such produces an
> error.
> > So
> > 1990 would be 199.  The dob is being inputted by a form....
> >
> > Here is my code:
> >
> > if (!ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", $formsave["dob"],
> $parts))
> > {
> >  $error["dob"] = "*"; $message["dob"] = "Invalid date format!";
> >  $dob = " \"$parts[3]-$parts[2]-$parts[1]\"";
> > }
>
> So is $formsave['dob'] being changed before you get to this code,
> causing the check to fail? What else are you doing with
> $formsave['dob']? Nothing here is going to cause it to drop a zero from
> the end.
>
> Your code doesn't make much sense, though. If the ereg() fails, $parts
> is not going to have any value, so why are you referencing $part[1],
> $part[2], etc... ?
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to