Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-20 Thread Jasen Betts
On 2009-08-19, Clemens Schwaighofer clemens_schwaigho...@e-gra.co.jp wrote:
 On Wed, Aug 19, 2009 at 02:11, Randal L. Schwartzmer...@stonehenge.com 
 wrote:
 Andre == Andre Lopes lopes80an...@gmail.com writes:

 Andre I'm developing a function with some checks, for example... to check 
 if the
 Andre e-mail is valid or not.

 How are you hoping to do this?  The regex to validate an email
 address syntactically is pretty large:

  http://ex-parrot.com/~pdw/Mail-RFC822-Address.html

 And no, I'm not kidding.  If your regex is smaller than that, you aren't
 validating email... you're validating something kinda like email.

 Just in my opinion, this regex is completely too large. For basic
 validating something like:
 ^[A-Za-z0-9!#$%'*+-\/=?^_`{|}~][A-Za-z0-9!#$%'*+-\/=?^_`{|}~\.]{0,6...@[a-za-z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,4}){1}$
 works very well

not good: eg:

fails this valid address* : ad...@xxx.museum
accepts this invalid one  : y...@gmail..com

musedoma replaced with several x to protect the innocent from spam

in some contexts email adrresses with no domain part are valid
addresses with [bracketed] mx servers instead of a domain and/or bang
paths are also allowed (but not in common use and often not desirable)




-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-20 Thread Jasen Betts
On 2009-08-20, Randal L. Schwartz mer...@stonehenge.com wrote:
 Clemens == Clemens Schwaighofer clemens_schwaigho...@e-gra.co.jp 
 writes:

Clemens I am not going to defend any regex here, but in my opinion it helps on
Clemens what I want to see in email addresses.
Clemens Yes it fails on mobile, but I have not yet seen one.

 And that's the problem.  You get near-sighted if you put up a strong
 validation for only things that *you* have seen.  Because, guess what,
 nobody outside your narrow view can sign up or be a customer.

 Bad for business.

Clemens  Probably the best
Clemens thing is to test nothing at all. Just accept it ...

 Exactly!  If you don't want to use the 950-character regex, DON'T DO
 ANYTHING AT ALL.  Far simpler.

Or do an MX lookup on the domain part (or a partial attempt to route
mail*) before sending it to the database.

*contact the domains MX and in SMTP go as far as RCPT TO: ...  and
then send QUIT after it is accepted or refused.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-20 Thread Sam Mason
On Thu, Aug 20, 2009 at 01:03:47PM +, Jasen Betts wrote:
 On 2009-08-20, Randal L. Schwartz mer...@stonehenge.com wrote:
  Exactly!  If you don't want to use the 950-character regex, DON'T DO
  ANYTHING AT ALL.  Far simpler.
 
 Or do an MX lookup on the domain part (or a partial attempt to route
 mail*) before sending it to the database.
 
 *contact the domains MX and in SMTP go as far as RCPT TO: ...  and
 then send QUIT after it is accepted or refused.

Why not just go the whole way and send an email asking for confirmation?
When you get a response you know the email address is actually useful
for contacting the user, rather than it being a typo and going somewhere
else.

-- 
  Sam  http://samason.me.uk/

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-20 Thread Clemens Schwaighofer
On Thu, Aug 20, 2009 at 21:52, Jasen Bettsja...@xnet.co.nz wrote:
 On 2009-08-19, Clemens Schwaighofer clemens_schwaigho...@e-gra.co.jp wrote:
 On Wed, Aug 19, 2009 at 02:11, Randal L. Schwartzmer...@stonehenge.com 
 wrote:
 Andre == Andre Lopes lopes80an...@gmail.com writes:

 Andre I'm developing a function with some checks, for example... to check 
 if the
 Andre e-mail is valid or not.

 How are you hoping to do this?  The regex to validate an email
 address syntactically is pretty large:

  http://ex-parrot.com/~pdw/Mail-RFC822-Address.html

 And no, I'm not kidding.  If your regex is smaller than that, you aren't
 validating email... you're validating something kinda like email.

 Just in my opinion, this regex is completely too large. For basic
 validating something like:
 ^[A-Za-z0-9!#$%'*+-\/=?^_`{|}~][A-Za-z0-9!#$%'*+-\/=?^_`{|}~\.]{0,6...@[a-za-z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,4}){1}$
 works very well

 not good: eg:

 fails this valid address* : ad...@xxx.museum

yes it does, but all I need to change is {2,4}, to {2,6} or {2,}

 accepts this invalid one  : y...@gmail..com

and not it does not. I just tested it here.

The regex helps to avoid stuff like this:

f...@bar.com
foo@@bar.com
f...@.bar.com
f...@bar

etc


 musedoma replaced with several x to protect the innocent from spam

 in some contexts email adrresses with no domain part are valid
 addresses with [bracketed] mx servers instead of a domain and/or bang
 paths are also allowed (but not in common use and often not desirable)




 --
 Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
 To make changes to your subscription:
 http://www.postgresql.org/mailpref/pgsql-general




-- 
★ Clemens 呉 Schwaighofer
★ IT Engineer/Web Producer/Planning
★ E-Graphics Communications SP Digital
★ 6-17-2 Ginza Chuo-ku, Tokyo 104-8167, JAPAN
★ Tel: +81-(0)3-3545-7706
★ Fax: +81-(0)3-3545-7343
★ http://www.e-gra.co.jp
This e-mail is intended only for the named person or entity to which it is 
addressed and contains valuable business information that is privileged, 
confidential and/or otherwise protected from disclosure. If you received this 
e-mail in error, any review, use, dissemination, distribution or copying of 
this e-mail is strictly prohibited.   Please notify us immediately of the error 
via e-mail to disclai...@tbwaworld.com and please delete the e-mail from your  
system, retaining no copies in any media.We appreciate your cooperation.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-19 Thread Michael Glaesemann


On Aug 18, 2009, at 16:45 , Scott Marlowe wrote:

On Tue, Aug 18, 2009 at 10:57 AM, Andre  
Lopeslopes80an...@gmail.com wrote:
I need to know if it is possible to show this RAISE NOTICE when I  
run this

function from PHP.


http://www.php.net/manual/en/function.pg-last-notice.php


Thanks, Scott.

Is there an equivalent in PDO? Looking through the docs I don't see  
one. It'd also be nice to be able to get at any/all of the additional  
information that's passed back: warning, context, hint, etc.


Michael Glaesemann
grzm seespotcode net




--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-19 Thread Randal L. Schwartz
 Clemens == Clemens Schwaighofer clemens_schwaigho...@e-gra.co.jp 
 writes:

Clemens Just in my opinion, this regex is completely too large. For basic
Clemens validating something like:
Clemens 
^[A-Za-z0-9!#$%'*+-\/=?^_`{|}~][A-Za-z0-9!#$%'*+-\/=?^_`{|}~\.]{0,6...@[a-za-z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,4}){1}$
Clemens works very well

Fails on .mobile TLD.  Has a pointless {1} in it, which does
absolutely nothing, providing that the creator of the regex was already
missing a few clues.

That's the problem with these kinds of regex... you test it on what
you know, but you're not consulting the *actual* *internet* specifications
(which have been readily available since the dawn of Internet time).

Either use the regex I pointed to already, or stay with the simpler:

  /\...@.*\s/

which will at least not deny anyone with a *perfectly legitimate* email
address from making it into your system.

Or, use your regex *only* in an *advice* category, with the ability
for the user to say yes, I'm really sure this is my address.

Please, for the sake of the net, do the Right Thing here.  This is
what I'm arguing for.  Anything less than that, and your code deserves
to end up in thedailywtf.com as an example of what *not* to do.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-19 Thread Clemens Schwaighofer
On Wed, Aug 19, 2009 at 02:11, Randal L. Schwartzmer...@stonehenge.com wrote:
 Andre == Andre Lopes lopes80an...@gmail.com writes:

 Andre I'm developing a function with some checks, for example... to check if 
 the
 Andre e-mail is valid or not.

 How are you hoping to do this?  The regex to validate an email
 address syntactically is pretty large:

  http://ex-parrot.com/~pdw/Mail-RFC822-Address.html

 And no, I'm not kidding.  If your regex is smaller than that, you aren't
 validating email... you're validating something kinda like email.

Just in my opinion, this regex is completely too large. For basic
validating something like:
^[A-Za-z0-9!#$%'*+-\/=?^_`{|}~][A-Za-z0-9!#$%'*+-\/=?^_`{|}~\.]{0,6...@[a-za-z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,4}){1}$
works very well

 For example, fredbar...@stonehenge.com is a valid email address.  (Go
 ahead, try it... it has an autoresponder.)

 --
 Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
 To make changes to your subscription:
 http://www.postgresql.org/mailpref/pgsql-general




-- 
★ Clemens 呉 Schwaighofer
★ IT Engineer/Web Producer/Planning
★ E-Graphics Communications SP Digital
★ 6-17-2 Ginza Chuo-ku, Tokyo 104-8167, JAPAN
★ Tel: +81-(0)3-3545-7706
★ Fax: +81-(0)3-3545-7343
★ http://www.e-gra.co.jp
This e-mail is intended only for the named person or entity to which it is 
addressed and contains valuable business information that is privileged, 
confidential and/or otherwise protected from disclosure. If you received this 
e-mail in error, any review, use, dissemination, distribution or copying of 
this e-mail is strictly prohibited.   Please notify us immediately of the error 
via e-mail to disclai...@tbwaworld.com and please delete the e-mail from your  
system, retaining no copies in any media.We appreciate your cooperation.


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-19 Thread Scott Marlowe
On Wed, Aug 19, 2009 at 8:41 AM, Randal L.
Schwartzmer...@stonehenge.com wrote:
 Clemens == Clemens Schwaighofer clemens_schwaigho...@e-gra.co.jp 
 writes:

 Clemens Just in my opinion, this regex is completely too large. For basic
 Clemens validating something like:
 Clemens 
 ^[A-Za-z0-9!#$%'*+-\/=?^_`{|}~][A-Za-z0-9!#$%'*+-\/=?^_`{|}~\.]{0,6...@[a-za-z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,4}){1}$
 Clemens works very well

 Fails on .mobile TLD.  Has a pointless {1} in it, which does
 absolutely nothing, providing that the creator of the regex was already
 missing a few clues.

Remonds me of the saying that for every complex problem there is a
simple, elegant and incorrect solution.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-19 Thread David Fetter
On Wed, Aug 19, 2009 at 11:57:45AM -0600, Scott Marlowe wrote:
 On Wed, Aug 19, 2009 at 8:41 AM, Randal L.
 Schwartzmer...@stonehenge.com wrote:
  Clemens == Clemens Schwaighofer clemens_schwaigho...@e-gra.co.jp 
  writes:
 
  Clemens Just in my opinion, this regex is completely too large. For basic
  Clemens validating something like:
  Clemens 
  ^[A-Za-z0-9!#$%'*+-\/=?^_`{|}~][A-Za-z0-9!#$%'*+-\/=?^_`{|}~\.]{0,6...@[a-za-z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,4}){1}$
  Clemens works very well
 
  Fails on .mobile TLD.  Has a pointless {1} in it, which does
  absolutely nothing, providing that the creator of the regex was already
  missing a few clues.
 
 Remonds me of the saying that for every complex problem there is a
 simple, elegant and incorrect solution.

That's from H. L. Mencken.

For every complex problem, there is an answer which is clear,
simple, and wrong.

Cheers,
David.
-- 
David Fetter da...@fetter.org http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter  XMPP: david.fet...@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-19 Thread Randal L. Schwartz
 Clemens == Clemens Schwaighofer clemens_schwaigho...@e-gra.co.jp 
 writes:

Clemens I am not going to defend any regex here, but in my opinion it helps on
Clemens what I want to see in email addresses.
Clemens Yes it fails on mobile, but I have not yet seen one.

And that's the problem.  You get near-sighted if you put up a strong
validation for only things that *you* have seen.  Because, guess what,
nobody outside your narrow view can sign up or be a customer.

Bad for business.

Clemens  Probably the best
Clemens thing is to test nothing at all. Just accept it ...

Exactly!  If you don't want to use the 950-character regex, DON'T DO
ANYTHING AT ALL.  Far simpler.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-19 Thread Clemens Schwaighofer
On 08/19/2009 11:41 PM, Randal L. Schwartz wrote:
 Clemens == Clemens Schwaighofer clemens_schwaigho...@e-gra.co.jp 
 writes:
 
 Clemens Just in my opinion, this regex is completely too large. For basic
 Clemens validating something like:
 Clemens 
 ^[A-Za-z0-9!#$%'*+-\/=?^_`{|}~][A-Za-z0-9!#$%'*+-\/=?^_`{|}~\.]{0,6...@[a-za-z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,4}){1}$
 Clemens works very well
 
 Fails on .mobile TLD.  Has a pointless {1} in it, which does
 absolutely nothing, providing that the creator of the regex was already
 missing a few clues.
 
 That's the problem with these kinds of regex... you test it on what
 you know, but you're not consulting the *actual* *internet* specifications
 (which have been readily available since the dawn of Internet time).
 
 Either use the regex I pointed to already, or stay with the simpler:
 
   /\...@.*\s/
 
 which will at least not deny anyone with a *perfectly legitimate* email
 address from making it into your system.
 
 Or, use your regex *only* in an *advice* category, with the ability
 for the user to say yes, I'm really sure this is my address.
 
 Please, for the sake of the net, do the Right Thing here.  This is
 what I'm arguing for.  Anything less than that, and your code deserves
 to end up in thedailywtf.com as an example of what *not* to do.

I am not going to defend any regex here, but in my opinion it helps on
what I want to see in email addresses.
Yes it fails on mobile, but I have not yet seen one. Probably the best
thing is to test nothing at all. Just accept it ...


-- 
[ Clemens Schwaighofer  -=:~ ]
[ IT Engineer/Web Producer/Planning  ]
[ E-Graphics Communications SP Digital   ]
[6-17-2 Ginza Chuo-ku, Tokyo 104-8167, JAPAN ]
[ Tel: +81-(0)3-3545-7706Fax: +81-(0)3-3545-7343 ]
[ http://www.e-gra.co.jp ]



signature.asc
Description: OpenPGP digital signature


[GENERAL] Postgre RAISE NOTICE and PHP

2009-08-18 Thread Andre Lopes
Hi,

I'm developing a function with some checks, for example... to check if the
e-mail is valid or not.

If the e-mail is not valid I put a line with RAISE NOTICE 'E-mail not
valid'.

I need to know if it is possible to show this RAISE NOTICE when I run this
function from PHP.


Best Regards,
André.


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-18 Thread Randal L. Schwartz
 Andre == Andre Lopes lopes80an...@gmail.com writes:

Andre I'm developing a function with some checks, for example... to check if 
the
Andre e-mail is valid or not.

How are you hoping to do this?  The regex to validate an email
address syntactically is pretty large:

  http://ex-parrot.com/~pdw/Mail-RFC822-Address.html

And no, I'm not kidding.  If your regex is smaller than that, you aren't
validating email... you're validating something kinda like email.

For example, fredbar...@stonehenge.com is a valid email address.  (Go
ahead, try it... it has an autoresponder.)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-18 Thread Scott Marlowe
On Tue, Aug 18, 2009 at 10:57 AM, Andre Lopeslopes80an...@gmail.com wrote:
 Hi,

 I'm developing a function with some checks, for example... to check if the
 e-mail is valid or not.

 If the e-mail is not valid I put a line with RAISE NOTICE 'E-mail not
 valid'.

 I need to know if it is possible to show this RAISE NOTICE when I run this
 function from PHP.

http://www.php.net/manual/en/function.pg-last-notice.php

example plpgsql function:
create or replace function tester() returns int language plpgsql as $$
BEGIN
raise notice 'whoops';
return 1;
END
$$;

example php:
?php
$conn = pg_connect(dbname=smarlowe);
$res = pg_query(select tester());
print pg_last_notice($conn);
print \n;
?

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] Postgre RAISE NOTICE and PHP

2009-08-18 Thread Adam Rich

Andre,
See this PHP page:

http://www.php.net/manual/en/function.pg-last-notice.php



Andre Lopes wrote:

Hi,

I'm developing a function with some checks, for example... to check if 
the e-mail is valid or not.


If the e-mail is not valid I put a line with RAISE NOTICE 'E-mail not 
valid'.


I need to know if it is possible to show this RAISE NOTICE when I run 
this function from PHP.



Best Regards,
André.





--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general