RE: [PHP] Ereg question

2003-03-30 Thread John W. Holmes
 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



Re: [PHP] Ereg question

2003-03-30 Thread Beauford
$parts has been removed as I found I didn't need it there, but the problem
still exists. This part of code however may be causing the problem, although
I thought trim only stripped white space.?.  $formsave['dob']  is a
session variable.  I have also found now that leading 0's are also being
stripped.

foreach($HTTP_POST_VARS as $varname = $value)
  $formsave[$varname] = trim($value, 50);

If it's not there then the whole script fails.

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



Re: [PHP] Ereg question

2003-03-30 Thread Beauford
This is what I get when I echo $formsave[dob]  - 9/09/199.  It was
inputted as 09/09/1990.

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



Re: [PHP] Ereg question

2003-03-30 Thread Beauford
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



RE: [PHP] Ereg question

2003-03-30 Thread John W. Holmes
 I thought trim only stripped white space.?.  $formsave['dob']  is
a
 session variable.  I have also found now that leading 0's are also
being
 stripped.
 
 foreach($HTTP_POST_VARS as $varname = $value)
   $formsave[$varname] = trim($value, 50);
 
 If it's not there then the whole script fails.

Why do you have the 50 there in the trim() function? That's what's
causing your problems. You're removing all fives and zeros from the
beginning and end of your string, along with any white space. 

---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



Re: [PHP] Ereg question

2003-03-30 Thread Jason Wong
On Monday 31 March 2003 04:15, Beauford wrote:
 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.

Having read the whole thread it seems that you're only disclosing information 
when it's been totured out of you :)

May I suggest that in order to save yourself and other people's time that you 
give FULL and ACCURATE information. 

For example, at the start of the thread you're pinning the blame on your ereg, 
then you're saying the session variable is the problem. Only after it has 
been pointed out to you that what you say you're doing cannot possibly have 
the effect that you say you're seeing, do you finally disclose that you're 
using trim() on the vital variables.

Put simply, if you had posted your full and unadulterated code right from the 
start then this thread should/would/could have been resolved in about 2 
posts. Saving time and frustration for everyone involved.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Bit off more than my mind could chew,
Shower or suicide, what do I do?
-- Julie Brown, Will I Make it Through the Eighties?
*/


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



Re: [PHP] Ereg question

2003-03-30 Thread Beauford
I posted the information as I had it. I had no idea what the problem was and
posted the information I thought was FULL and ACCURATE - if this isn't good
enough - then maybe I'll look for another list where people are a little
more forgiving of new users. Remember, you were in my shoes once.

B.

- Original Message -
From: Jason Wong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, March 30, 2003 11:20 PM
Subject: Re: [PHP] Ereg question


 On Monday 31 March 2003 04:15, Beauford wrote:
  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.

 Having read the whole thread it seems that you're only disclosing
information
 when it's been totured out of you :)

 May I suggest that in order to save yourself and other people's time that
you
 give FULL and ACCURATE information.

 For example, at the start of the thread you're pinning the blame on your
ereg,
 then you're saying the session variable is the problem. Only after it has
 been pointed out to you that what you say you're doing cannot possibly
have
 the effect that you say you're seeing, do you finally disclose that you're
 using trim() on the vital variables.

 Put simply, if you had posted your full and unadulterated code right from
the
 start then this thread should/would/could have been resolved in about 2
 posts. Saving time and frustration for everyone involved.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Bit off more than my mind could chew,
 Shower or suicide, what do I do?
 -- Julie Brown, Will I Make it Through the Eighties?
 */


 --
 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



Re: [PHP] Ereg question

2003-03-30 Thread Jason Wong
On Monday 31 March 2003 13:58, Beauford wrote:

 I posted the information as I had it. I had no idea what the problem was
 and posted the information I thought was FULL and ACCURATE - 

Full and accurate if taken literally are absolute terms and are objective not 
subjective.

 if this isn't
 good enough - then maybe I'll look for another list where people are a
 little more forgiving of new users. Remember, you were in my shoes once.

Jeez, my suggestion was to make it easier for others to help you. If you 
insist you can always continue to post your question in installments (don't 
forget a teaser to whet people's appetite for the next episode). And yes, you 
can also look for another list if you want. These are all your choices.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Things are not always what they seem.
-- Phaedrus
*/


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



Re: [PHP] Ereg question

2003-03-30 Thread Beauford
This likely won't get through, but if it does. Post a real address so these
conversations don't go through the list. I mean I'm already a burden to the
list as it is.

B.

- Original Message -
From: Jason Wong [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 31, 2003 1:36 AM
Subject: Re: [PHP] Ereg question


 On Monday 31 March 2003 13:58, Beauford wrote:

  I posted the information as I had it. I had no idea what the problem was
  and posted the information I thought was FULL and ACCURATE -

 Full and accurate if taken literally are absolute terms and are objective
not
 subjective.

  if this isn't
  good enough - then maybe I'll look for another list where people are a
  little more forgiving of new users. Remember, you were in my shoes once.

 Jeez, my suggestion was to make it easier for others to help you. If you
 insist you can always continue to post your question in installments
(don't
 forget a teaser to whet people's appetite for the next episode). And yes,
you
 can also look for another list if you want. These are all your choices.

 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 Things are not always what they seem.
 -- Phaedrus
 */


 --
 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



Re: [PHP] Ereg question

2003-03-30 Thread Peter Houchin
Beauford, Jason,

Build a bridge and get over it already sheeesh

TYVMIA
Peter


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


Re: [PHP] ereg question

2001-09-02 Thread Papp Gyozo

Hello,

check it in the manual: http://www.php.net/manual/en/function.ereg.php

If you don't pass the third -- optional -- argument, then it's true.
Otherwise not.

I don't know this book, but you may keep in my mind that PHP is evolving,
so the online manual can be its most up-to-date documentation.

- Original Message -
From: js [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, September 02, 2001 3:05 AM
Subject: [PHP] ereg question


 In the Leon Atkinson Core PHP book, in his ereg example he states that
ereg
 will only return the first match on a line.  Can anyone confirm or deny
this?

 Thanks,
 Josh


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]