> -----Original Message----- > From: 'Roman Neuhauser' [mailto:neuhauser@xxxxxxxxxx] > Sent: January 15, 2007 7:53 PM > To: Beauford > Cc: 'PHP' > Subject: Re: I lied, another question / problem > > # phpuser@xxxxxxxxxx / 2007-01-15 18:33:31 -0500: > > > From: Roman Neuhauser [mailto:neuhauser@xxxxxxxxxx] # > > > phpuser@xxxxxxxxxx / 2007-01-15 16:31:32 -0500: > > > > I have file which I use for validating which includes the > > > > following > > > > function: > > > > > > > > function invalidchar($strvalue) > > > > { > > > > if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) { > > > > > > That regexp matches if $strvalue consists of zero or more > ocurrences > > > of a letter, a whitespace character, and any character > whose numeric > > > value lies between the numeric values of "'" and "." in > your locale. > > > Zero or more means it also matches an empty string. > > > > I'm still confused. This works perfectly on my other two pages with > > the exact same code. So why is it only this one page that > is causing a problem? > > I don't know, I don't care. You have enough problems with the > single regex, let's concentrate on fixing this first. This certainly has a bearing. If the code works here then there is nothing wrong with the code. There is something else going on. > > If I enter the word "test" in my form, without the quotes, > then why is > > the fuction returning anything since this is a valid entry. > Should it > > not only return a value if there is a problem. > > I don't understand that paragraph. The regexp matches, and > the function returns *nothing* just as you programmed it. > That, of course, means that the variable you are assigning > this *nothing* gets set to *nothing*, which, in PHP lingo, is null. The problem is that it is returning *something*, and that's what I am trying to figure out. If I put this in my code after I do the checking it works, but it should not work if the function is retuning *nothing*. So the original question remains, what is being returned and why? If($formerror) echo "Testing"; This will display Testing - it should not display anything since nothing should be returned. > > > All I want to accomplish here is to allow the user to enter > a to z, A > > to Z, and /\'-_. and a space. Is there a better way to do this? > > 1. Do you really want to let them enter backslashes, or are you trying > to "escape" the apostrophe? > 2. Does that mean that "/\'-_." (without the quotes) and " " (that's > three spaces) are valid entries? Where do you see 3 spaces? In any event, I don't think this is the problem. As I have said the code works fine on two other pages, which logically suggests that there is something on this page that is causing a problem. Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php